Can Front Page Display 'Featured' Category?

Home Forums Support Can Front Page Display 'Featured' Category?

Home Forums Support Can Front Page Display 'Featured' Category?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #141681
    duane

    Is there a way with the premium add-ons to modify what my front page displays to something other than ‘latest posts’ or ‘static page’? What I am most interested in is another display option being ‘category’, such as ‘Featured’, and then only the latest posts from this single category would be displayed on the front page.

    #141717
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You could try a function like this:

    add_action( 'pre_get_posts', 'my_home_category' );
    function my_home_category( $query ) { 
        if ( $query->is_front_page() && $query->is_main_query() ) { 
            $query->set( 'cat', '11'); 
        } 
    }

    You would have to adjust the “11” to the ID of the category you want to display.

    Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/

    #222701
    Rebecca

    Hi Tom,
    Quick question! I just tried your suggested php to set a category as the front page and it worked , but when you scroll down the page you still see the latest posts. How can I fix this?
    Many thanks
    Rebecca

    #222793
    Tom
    Lead Developer
    Lead Developer

    Can you link me to the site?

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.