Archived topic
Adding columns to your custom post type
15 replies · Started by Quested on March 21, 2022
Hi
I want to add columns to my custom post type. I tried many times but its not working. Custom Post Type archive name is Projects.
I already gone through this article. https://docs.generatepress.com/article/using-columns-in-the-blog/#adding-columns-to-your-custom-post-type
Kindly help.
Humble Regards
Quested
Hi there,
Try this PHP snippet:
add_filter( 'generate_blog_columns', function( $columns ) {
if ( 'projects' === get_post_type() && ! is_singular() ) {
return true;
}
return $columns;
} );
Make sure you've set the column setting at customizer > layout > blog.
Awesome.
Worked perfectly.
Thank you so much for the help.
You are welcome :)
Hi
I am redesigning another website from Divi to GeneratePress. I want to add columns to my custom post type. I tried many times but its not working. Custom Post Type archive name is Reviews.
Hi there,
can you share the exact code you added ?
I have given you temporary access to my site.
Where did you add the PHP Snippet ? I don't see it on your site
You can check the Theme Editor.
I added the code again.
You can add or edit the code. You have full control.
Ok check now.
I changed the post type slug to review
Thank you so much for your help.
You're welcome!
I want to add same 3 columns to my another custom post type. Custom Post Type archive name is Buyer Guides.
I have given you full access to check the code in Theme Editor. You can make the changes required.
Change this code:
add_filter( 'generate_blog_columns', function( $columns ) {
if ( 'review' === get_post_type() && ! is_singular() ) {
return true;
}
return $columns;
} );
to this code:
add_filter( 'generate_blog_columns', function( $columns ) {
if ( ( 'review' === get_post_type() || 'buyer-guides' === get_post_type() ) && ! is_singular() ) {
return true;
}
return $columns;
} );
You guys are awesome.
Thank you so much for quick help.