The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Setting the front page to specific category archive - 2013 (2 posts)

  1. garrettmojica
    Posted 3 years ago #

    I'm looking to get some help on setting the front page so that it will only display posts from a specific category archive.

    Does anyone know how to do this?

    Any help to previous threads, articles or tutorials would be greatly appreciated.

  2. Jesper van Engelen
    Posted 3 years ago #

    There seems to be a plugin available that was created solely for this purpose: http://wordpress.org/extend/plugins/frontpage-category-filter/.

    If you would like to go for a non-plugin approach, you could hook into the pre_get_posts action to manipulate the main query. Make sure you first check whether it is the home page and whether the query you are checking is actually the main query.

    function yourprefix_homepage_query_category($query)
    	if ($query->is_home() && $query->is_main_query()) {
    		$query->set('cat', YOUR_CATEGORY_ID);
    add_action('pre_get_posts', 'yourprefix_homepage_query_category');

    You can check out the Codex entry for pre_get_posts, where you will find an example for excluding certain categories, which is very similar to what you're trying to achieve.


Topic Closed

This topic has been closed to new replies.

About this Topic