I want to edit the tags of the current post on the front end, my code is like this,
$args =array();
$directory_url=get_option('_iv_directory_url');
if($directory_url==""){$directory_url='directories';}
$dir_tags=get_option('_dir_tags');
if($dir_tags==""){$dir_tags='yes';}
if($dir_tags=='yes'){
$args2 = array(
'type' => $directory_url,
//'parent' => $term_parent->term_id,
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 0,
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'number' => '',
'taxonomy' => $directory_url.'_tag',
'pad_counts' => false
);
$main_tag = get_categories( $args2 );
$tags_all= wp_get_object_terms( $post_edit->ID, $post_type.'_tag');
if ( $main_tag && !is_wp_error( $main_tag ) ) :
foreach ( $main_tag as $term_m ) {
$checked='';
foreach ( $tags_all as $term ) {
if( $term->term_id==$term_m->term_id){
$checked=' checked';
}
}
I am getting error Trying to get property 'term_id' of non-object. how can i solve this.