- This topic has 8 replies, 2 voices, and was last updated 7 months, 2 weeks ago by
David.
-
AuthorPosts
-
June 1, 2020 at 10:46 am #1310162
Pavla
Hi! I need to customise various Category pages and the main blog page.
What I need to achieve is:
Category pages
Random posts order
Exclude pages (I use categories for pages because of dynamic widgets and other things)
Control how many posts are showed on the first page
Posts in columns or notBlog Page
Exclude pages (I use categories for pages because of dynamic widgets and other things)
Exclude some categories from main blog page
Random posts orderI guess i could achieve it somehow with filters?
I also saw some sidebar errors on different category pages, which have the same structure.
e.g. ….category/empresas/hoteles/ the sidebar is sliding down, but in …/category/empresas/restaurantes/ its perfect.Thank you!
June 1, 2020 at 3:52 pm #1310417Tom
Lead DeveloperLead DeveloperHi there,
Changing the posts per page is quite complex because of pagination: https://wordpress.stackexchange.com/questions/155758/have-different-number-of-posts-on-first-page
For the rest, you could try something like this:
add_action( 'pre_get_posts', function( $query ) { if ( is_admin() || ! $query->is_main_query() ) { return; } if ( $query->is_category() ) { // Category pages. $query->set( 'orderby', 'rand' ); // Random order $query->set( 'post_type', array( 'post', 'another-post-type', 'something-else' ) ); // What post types to include } if ( $query->is_home() ) { // Blog page. $query->set( 'orderby', 'rand' ); // Random order $query->set( 'post_type', array( 'post', 'another-post-type', 'something-else' ) ); // What post types to include $query->set( 'cat', '-10' ); // Exclude category 10 } } );
For columns, this should help: https://docs.generatepress.com/article/using-columns-in-the-blog/#adding-columns-to-your-custom-post-type
If your sidebar is broken (moving down the page), it typically means you have some broken HTML on the page. So an opening element (
<div>
for example) without a closing element (</div>
).Hope this helps!
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentJune 2, 2020 at 2:42 am #1310872Pavla
ok! i’ll try that! and can i remove the excerpts completely from the blog page and the category page so i have only featured image, title and meta tags of categories?
June 2, 2020 at 5:11 am #1311003David
StaffCustomer SupportHi there,
you can set the excerpt to
0
in Customizer > Layout > BlogDocumentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/June 2, 2020 at 3:14 pm #1311855Pavla
excerpt: i did that but it doesn’t work, still showing it.
June 3, 2020 at 2:39 am #1312184David
StaffCustomer SupportAre you using Manual Excerpts or Read More on some of your posts ? If so the auto excerpt does not apply.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/June 7, 2020 at 8:37 am #1318094Pavla
ok perfect that made it, thanks!
June 7, 2020 at 8:37 am #1318095Pavla
closing
June 7, 2020 at 10:02 am #1318195David
StaffCustomer SupportYou’re welcome
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.