Skip to content

Instantly share code, notes, and snippets.

@rfmeier
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save rfmeier/c25d33a4bc577d734bcb to your computer and use it in GitHub Desktop.

Select an option

Save rfmeier/c25d33a4bc577d734bcb to your computer and use it in GitHub Desktop.
Set the WordPress home to use the archive template.
<?php
/**
* Do not include the <?php tag... your functions.php should already have one.
*
* In response to Genesis support forums.
* http://www.studiopress.com/forums/topic/minimum-pro-archive-portfolio-for-catgeory-archive-pages-and-home-page/
*/
add_action( 'pre_get_posts', 'custom_pre_get_posts' );
/**
* Callback for WordPress 'pre_get_posts' action.
*
* @param object $wp_query The current WP_Query object.
* @return void
*/
function custom_pre_get_posts( $wp_query ) {
// if admin, return
if( is_admin() )
return;
// if not home, return
if( ! $wp_query->is_home() )
return;
// if not within main WP_Query, return
if( ! $wp_query->is_main_query() )
return;
// tell WordPress we are in the archives... tee-hee
$wp_query->is_home = false;
$wp_query->is_archive = true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment