When working with thumbnails, I want to display in the admin page and it has nothing to do with the 'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields' ),
Yes. That part looks correct. I suspect the issue is that you’re hooking the first bit to a portfolio post type and the second bit is (almost) hooked to the core post post type. You’ll need to make a couple of changes.
manage_portfolio_posts_columns
manage_posts_custom_column
…should be as follows to hook into the core posts list:
manage_post_posts_columns
manage_post_posts_custom_column
…or as follows to hook in to a CPT list for a portfolio post type:
so i change itto this, but for some reason the categories is not showing up properly… since this is the portfolio categories, the portfolio_category is the taxonomy that’s get register to the portfolio cpt.
This doesn’t help much. It looks like you added var_dumpafter modifying the array instead of before as suggested, and you haven’t posted the code you were using so we can’t tell if you may have made some other mistake.
Anyway, probably best to do it more like this, to keep all the columns that were already set and avoid interfering with other plugins…
$columns_new = [];
foreach ( $columns as $key => $value ) {
$columns_new[ $key ] = $value;
if ( $key === 'title' ) {
// Add 'thumbnail' after 'title'
$columns_new['thumbnail'] = __( 'Thumbnail', 'luthemes' );
}
}
// If the 'title' column is not set then the 'thumbnail' column won't be
// added either. This is probably not worth worrying about.
return $columns_new;