How to use a specific category archive index as the site front page?

Create a file front-page.php with the following content:

locate_template( 'category-image-gallery.php', TRUE, TRUE );

That’s all.

For the theme’s functions.php

If you want to restrict the front page content to posts from that category, filter the front page query:

add_action( 'pre_get_posts', 'wpse_74225_frontpage_categories' );

function wpse_74225_frontpage_categories( $query ) 
{
    if ( $query->is_main_query() && is_front_page() ) 
    {
        $query->set( 'category_name', 'image-gallery' );
    }

    return $query;
}

But that would create a copy of your category archive: duplicate content, not a good idea if you want both pages be found in search engines.

To avoid links to that category archive you have to filter 'term_link' too:

add_filter( 'term_link', 'wpse_74225_category_link', 10, 2 );

function wpse_74225_category_link( $link, $term )
{
    if ( 'image-gallery' === $term->slug )
        return home_url();

    return $link;
}

Leave a Comment