Archived topic
A Single Category/Front Page/Maintain Layout Features
5 replies · Started by Jennifer on February 6, 2021
Greetings,
I need to create the ability for my site to:
1. "only show a single category" on the front page
2. Maintain the layout that I have set in the Gp: Blog ▸ Customizing ▸ Layout
which are the - 3 columns - make post 1 featured and masonry (I love those Gp features - keeps me coming back -so awesome).
I was curious, how would you use best practices to achieve the above?
Here is a link to the site: layout is perfect, I just want ONLY Cat_ID=5 aka "headlines" to display.
Weekly Word News
THANK YOU LOVELY Gp PEOPLE,
Jennifer
Hi Jennifer,
I believe this is what you are after:
https://generatepress.com/forums/topic/how-to-display-post-category-archive-as-home-page/#post-877735
Adding PHP: https://docs.generatepress.com/article/adding-php/
Hello, reading through that ticket is seems to be problematic when loading posts and using an off-set.
Also, where would I put that filter?
Do I create a child theme?
----- Where do I put this?------
`add_action( 'pre_get_posts', function( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'cat', '123' );
}
} );
Hi Jennifer,
This is how you add php:
Adding PHP: https://docs.generatepress.com/article/adding-php/
I personally would recommend to use Code Snippets :)
Ying and Leo,
Code Snippet worked great. Thank you for the excellent support.
- Jennifer
Glad we could help :)