Can’t get name for array of term_id from wp_set_object_terms inside admin post


I use

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'] ) )
            $tags = $_POST['rudr_select2_tags'];
            foreach ( $tags as $tag ): 
                $terms = get_term($tag); 
                $tags_asso = $terms->name;
            wp_set_object_terms($post_id, $tags_asso, 'post_tag') ;
            update_post_meta( $post_id, 'rudr_select2_tags', $_POST['rudr_select2_tags'] );
            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";}.

imagIne 8 months 2020-12-11T10:10:21-05:00 0 Answers 10 views 0

Leave an answer