How to make a category page the blog home page?

Update

Eliminating all of the other solutions, there is at least one remaining: template_redirect:

function wpse121308_redirect_homepage() {
    // Check for blog posts index
    // NOT site front page, 
    // which would be is_front_page()
    if ( is_home() ) {
        wp_redirect( get_category_link( $id ) );
        exit();
    }
}
add_action( 'template_redirect', 'wpse121308_redirect_homepage' );

You will need to pass the appropriate category $id, of course.

The benefit of redirecting at template_redirect is that you only get one template-load taking place, rather than a second redirect after the template loads.

Note that you can hook into the process even earlier, such as at pre_get_posts, thereby potentially saving an entire query request:

add_action( 'pre_get_posts', 'wpse121308_redirect_homepage' );

Original Answer

If all you want to do is display a specific category on the blog posts index, you can accomplish that with a simple filter of the main $wp_query at pre_get_posts:

function wpse1862_pre_get_posts( $query ) {
    // Only modify the main query
    // on the blog posts index page
    if ( is_home() && $query->is_main_query() ) {
        $query->set( 'category_name', 'category-slug-here' );
    }
}
add_action( 'pre_get_posts', 'wpse1862_pre_get_posts' );

If you want to modify the template, then you can do one of two things:

  1. Create a home.php with the desired markup
  2. Use template_redirect or home_template to force WordPress to include your category.php template.

Edit

And if you want the blog posts index URL to look like:

www.example.com/main

Then you can use a Static Front Page, and assign a static page called “main” as your blog posts index.

And if this is your objective:

I really want the redirect. I want the home page (http://example.com/) to redirect to the category page (which looks like http://example.com/main/)

…then the accepted answer is correct for your use case.

Leave a Comment