Homepage posts category

Hi. Is there a way to have only posts from a certain category show on the homepage? For now, all blog posts I have written show on the homepage.


Hello there,

Thank you for contacting us. Currently the theme doesn’t have setting for the same.

However, you’ll still be able to achieve it with this code snippet.

    function cali_child_filter_category_post( $query ) {
        if ( $query->is_home() && $query->is_main_query() && ! is_admin() ) {

          $taxquery = array(
                'taxonomy' => 'category',
                'field' 		=> 'slug',
                'terms' 		=> array('catslug'),
                'operator' => 'IN'

          $query->set( 'tax_query', $taxquery );

    add_action( 'pre_get_posts', 'cali_child_filter_category_post' );

Replace catslug with your post category slug name.

Add the code into your child theme’s functions.php file. In case you don’t use any child theme, you can use Code Snippets.

I hope this reply helps.

Stay safe.
Have an excellent day :slight_smile:

aThemes Support