Skip to content

Instantly share code, notes, and snippets.

@chriskoelle
Created December 2, 2013 00:09
Show Gist options
  • Save chriskoelle/7742659 to your computer and use it in GitHub Desktop.
Save chriskoelle/7742659 to your computer and use it in GitHub Desktop.
This changes the Wordpress template hierarchy to use archive.php instead of home.php for the posts page if the front page settings are set to display a static page
/**
* Archive Template for Posts Page
*
* This changes the Wordpress template hierarchy to use archive.php for the posts page
*
* @author Chris Koelle
*
* @param string $template
* @return string
*/
function nh_posts_page_archive_template( $template ) {
global $wp_query;
if( $wp_query->is_posts_page && get_query_template( 'archive' ) !== '' )
$template = get_query_template( 'archive' );
return $template;
}
add_filter( 'template_include', 'nh_posts_page_archive_template' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment