Archived topic
Can Front Page Display 'Featured' Category?
3 replies · Started by Anonymous on October 3, 2015
Is there a way with the premium add-ons to modify what my front page displays to something other than 'latest posts' or 'static page'? What I am most interested in is another display option being 'category', such as 'Featured', and then only the latest posts from this single category would be displayed on the front page.
Hi there,
You could try a function like this:
add_action( 'pre_get_posts', 'my_home_category' );
function my_home_category( $query ) {
if ( $query->is_front_page() && $query->is_main_query() ) {
$query->set( 'cat', '11');
}
}
You would have to adjust the "11" to the ID of the category you want to display.
Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/
Hi Tom,
Quick question! I just tried your suggested php to set a category as the front page and it worked , but when you scroll down the page you still see the latest posts. How can I fix this?
Many thanks
Rebecca
Can you link me to the site?