0

I have the following code creating some Columns and reordering them to my CPT.

// SHOW THE FEATURED IMAGE
function pessoas_custom_columns_data($column_name, $post_ID) {
    if ($column_name == 'featured_image') {
        $post_featured_image = cpt_pessoas_featured_image($post_ID);
        if ($post_featured_image) {
            echo '<img class="bg_fi_postlist" src="' . $post_featured_image . '" />';

        }
    }
}

function reorder_pessoas_columns( $columnspessoas ) {
    $columnspessoas = array(
        'cb'                    => $columnspessoas['cb'],
        'featured_image'        => __( 'Pessoas' ),
        'title'                 => __( 'Nome' ),  // Post Title
        'categorias_de_pessoas' => __( 'Categorias' ),  // Categories for my CPT
        'post_type'             => __( 'Tipo' ),
        'author'                => __( 'Autor' ),
        'date'                  => __( 'Date' ) // Published Date
    );
    return $columnspessoas;
}

add_action( 'manage_pessoas_posts_custom_column' , 'pessoas_custom_columns_data', 10, 2 );
add_filter( 'manage_pessoas_posts_columns', 'reorder_pessoas_columns' );

My question is: why 'categorias_de_pessoas' => __( 'Categorias' ), doesn't the show the content within the categories selected to my post? This is a taxonomy called 'categorias_de_pessoas'.

Thank you once again. AMP.

1
  • Does that column show when you don't use the filter?
    – vancoder
    Jul 7 at 20:34

1 Answer 1

1

why 'categorias_de_pessoas' => __( 'Categorias' ), doesn't the show the content within the categories selected to my post? This is a taxonomy called 'categorias_de_pessoas'.

That issue happened because you did not prepend the taxonomy (or array key or column name) with a taxonomy-. I.e. The correct format is: taxonomy-<taxonomy>. See WP_Posts_List_Table::column_default().

So to fix the issue, use this instead: 'taxonomy-categorias_de_pessoas' => __( 'Categorias' ),

And just wondering, why do you have a post_type column there?.. 🤔

1
  • 1
    Thank you for your help. The solution was adding taxonomy- before my category name just like you said: 'taxonomy-categorias_de_pessoas'
    – Horacsio
    Jul 18 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.