I Can’t get the post_tag name from term_id using wp_set_object_terms


I use https://rudrastyh.com/wordpress/select2-for-metaboxes-with-ajax.html.

I want to display the name of post_data inside widget tags of posts and mainly tags column inside posts list.

I can’t get the name or slug of term_id from wp_set_object_terms.
update_post_meta serialize automaticaly terms inside metabox.
"Foreach" work fine for frontend but not for backend and I have no error.

I tried that and other solutions whith no result:

function rudr_save_metaboxdata( $post_id, $post ) {

if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id;

// if post type is different from our selected one, do nothing
if ( $post->post_type == 'post' ) {
    if( isset( $_POST['rudr_select2_tags'] ) )
        update_post_meta( $post_id, 'rudr_select2_tags', $_POST['rudr_select2_tags'] );
        wp_set_object_terms($post_id, $_POST['rudr_select2_tags'], 'post_tag', false) ;
        delete_post_meta( $post_id, 'rudr_select2_tags' );
return $post_id;}}

"wp_set_object_terms($post_id, $_POST[‘rudr_select2_tags’], ‘post_tag’)" display only the term_id from serialize code (a:2:{i:0;s:2:"11";i:1;s:2:"23";}.
I tried some solutions without results.

imagIne 1 month 0 Answers 4 views 0

Leave an answer