Dazzling - homepage - categories - posts from selected category on blog page

Hello, looking to only show certain blog posts on the homepage.

Unfortunately, there is no option for this via Theme Options. However, there are still two solution for that.

  1. Find a plugin that helps with that. I am not aware of any but since this is a very basic functionality I believe that there should be some available.

  2. Use this code via functions.php or Child Theme functions.php to filter what category you want to display on front page blog. I have used category ID of 29 but you must select category ID from category you have on your website or otherwise this code will break your website. Use this code only if you are 100% sure what you are doing.

function dazzling_homepage_query_category($query)
{
	if ($query->is_home() && $query->is_main_query()) {
		$query->set('cat', 29 );
	}
}

add_action('pre_get_posts', 'dazzling_homepage_query_category');

thanks for the info. Is there a way to control the number of posts you see on the homepage?

Number of posts displayed on front page can be changed via WordPress dashboard >> Settings >> Reading >> “Blog pages show at most”.

Let me know if this helps.