- This topic has 9 replies, 2 voices, and was last updated 4 months, 2 weeks ago by
David.
-
AuthorPosts
-
October 21, 2022 at 1:18 am #2380823
David
Hello
I’ve set up a custom post type called products.
I’ve then set up a block element using the Element Type : Content template
This works fine and products are showing up…
https://www.alfies-antiques.com/products/I added this code so the custom post type shows in 3 columns
//ADD COLUMNS TO CUSTOM POST TYPES add_filter( 'generate_blog_columns', function( $columns ) { if ( 'products' === get_post_type() && ! is_singular() ) { return true; } return $columns; } );
My first questions is, how do I get it to show 2 columns on mobile?
My second questions is, why do the products not show up on standard taxonomy category pages…
https://www.alfies-antiques.com/category/handles-hooks/Thanks
DaveOctober 21, 2022 at 8:39 am #2381365David
StaffCustomer SupportHi there,
1. you can use this CSS to force the CPT columns to 2 on mobile:
@media (max-width: 768px) { .archive .generate-columns { width: 50% !important; } .archive .generate-columns { padding-left: 20px !important; } }
2. Category archives will only display the
post
post-type by default.
Use thepre_get_posts
hook to add others:function db_multi_post_type_categories($query) { if($query->is_main_query() && is_category()){ $query->set('post_type', ['post', 'your-post-type']); return; } } add_action('pre_get_posts', 'db_multi_post_type_categories');
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/October 21, 2022 at 8:50 am #2381382David
Thanks David – how do I show 2 columns on the post category archive page?
October 21, 2022 at 9:38 am #2381445David
StaffCustomer SupportI edited the CSS above to apply to all archives.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/October 23, 2022 at 11:01 am #2383274David
Thanks David
October 24, 2022 at 3:04 am #2383883David
StaffCustomer SupportYou’re welcome
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/October 31, 2022 at 7:11 am #2395200David
Hi David
So I’ve updated my custom post type archive layout, by setting up a new Element Block and using the new Element Type > Loop template, which is great by the way.
Is it possible for it to use the loop template for taxonomy category pages though? So for example this category only has one product assigned to it, but it’s showing all custom post type products…
Is it possible to set up a new loop template, that shows products per category? I don’t want to be setting it up loops for each individual category though.
https://www.alfies-antiques.com/category/desks/
Thanks
DaveOctober 31, 2022 at 8:18 am #2395612David
StaffCustomer SupportSo for the Loop Element – its designed to use the
Inherit Query from Template
option in the Query Loop Block.
Then if you set your Display Rules to eg. Category Archive, it will pull in just the posts that match that terms of the archive page the user is viewing.Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/October 31, 2022 at 9:10 am #2395699David
Thanks David, that’s great – loving the new loop template
November 1, 2022 at 1:08 am #2396318David
StaffCustomer SupportAwesome – glad to hear that!
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.