Sometimes you might need to exclude certain posts from Home/Front page.This post will help you to do that in Genesis Framework.
1. Create a category and assign the posts to that category.
2. Now go to Posts >> Categories
and Edit the category you just created.
3. In URL field of your browser.Note down the category ID.
Here is a code you will be using
/** Exclude certain category from posts */ add_action( 'pre_get_posts', 'be_exclude_category_from_blog' ); function be_exclude_category_from_blog( $query ) { if( $query->is_main_query() && $query->is_home() ) { $query->set( 'cat', '-156' ); } }
In the line
$query->set( 'cat', '-156' );
Replace 156
with the category ID you noted down from step 3.(Do not remove the negative sign)
if you want to exclude more than one category then separate each ID with comma.For example
$query->set( 'cat', '-156,-2' );
Paste the modified code in your child themes functions.php
and clear the cache.Now check the Home page.
Excluding Category from Blog Page Template
In Genesis you can create a blog page by using Blog page template.Incase you want to exclude category from Blog page then from WordPress Dashboard go to Genesis Settings Page.
Under the Blog Page Template option you can find a field called Exclude the following Category IDs.Paste the category ID you want to exclude.Use comma to separate the category ID if you want to exclude more than one categories.
Hope this tutorial helped you,Please share your thoughts about this post.