Archived topic
Custom post type archive
13 replies · Started by Daniele on July 22, 2021
Hi,
I created a CPT and I would like to display the posts in two columns, how can I achieve that?
Do I have to use css or any filter of the theme?
thanks!
Hi there,
see this article for enabling columns on custom post types:
This will then respect the columns set in the Customizer > Layout > Blog
thanks, worked
Glad to hear that!
Hi David,
how I could affect also the categories, for example https://styventamburo.com/category/dessert/ ?
Hi Daniele,
For standard category archives, you can activate the columns layout at customizer > layout > blog.
https://docs.generatepress.com/article/using-columns-in-the-blog/
Let me know if you need further assistance :)
Hello, I mean custom post type categories
Can you give the method a try?
Let me know if it works.
Hi Ying,
2 columns is already selected, but it does not work for the CPT categories.
I also used this snippet:
/* Add columns to cpt archives */
add_filter( 'generate_blog_columns','tu_portfolio_columns' );
function tu_portfolio_columns( $columns ) {
if ( is_post_type_archive( 'ricette' ) ) {
return true;
}
return $columns;
}
Hi Daniele,
Can you verify if the CPT slug used is correct?
We can help you check if you want. You can use the private information text field to provide backend access credentials. :D
Hi,
yes the slug is correct...
I will send you credentials in the private field...thanks!
Hi there,
try this snippet:
add_filter( 'generate_blog_columns', function( $columns ) {
if ( 'ricette' === get_post_type() && ! is_singular() ) {
return true;
}
return $columns;
} );
It perfectly worked. thanks David
You're welcome