Displaying only a specific category on your blog-homepage in WordPress 4.9.

Sometimes we need to add or display more than one category on the „home“ page of a website. This is pretty easy to realize. Just put the following little piece of code into your existing „fuctions.php“ of the „Parent-Theme“. Before you will have to identify the „category-ID“ of the category you want to display on the blog-homepage. Replace this „ID“ with the placeholder „45“ in the following code.

Where do i find the category id of the category i want to display?

function my_home_category( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( ‚cat‘, ’45‘);
add_action( ‚pre_get_posts‘, ‚my_home_category‘ );