Front page posts from specific category

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5709
    Giorgoski
    Guest

    i have my front page to show all the recent posts from all categories(default).
    I want my front page to show all the recent posts from a specific category and not from all.
    thank you

    #5711
    Ron
    Keymaster

    Add this on a child-theme’s functions.php
    Replace the number 10 with your chosen category ID.

    function frontier_home_category( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'cat', '10' );
        }
    }
    add_action( 'pre_get_posts', 'frontier_home_category' );

    Get the category ID by going to the category page ( Posts -> Categories ). Click on the category you want then on your browser’s address bar you can search for the number ( ex. tag_ID=90 )

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Frontier’ is closed to new topics and replies.