Optimal way to redirect home page to category archive?

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.

Edit

As per @Milo’s comment, you could also try hooking into the process even earlier, at pre_get_posts, thereby potentially saving an entire query request:

add_action( 'pre_get_posts', 'wpse121308_redirect_homepage' );

Leave a Comment