Skip to content

Instantly share code, notes, and snippets.

@BjornW
Created November 9, 2010 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BjornW/669261 to your computer and use it in GitHub Desktop.
Save BjornW/669261 to your computer and use it in GitHub Desktop.
Trying to fix WordPress' is_home functionality with custom post types [DOES NOT WORK]
/**
* Makes sure the context is correct and set ordering to use custom fields
*
* Courtesy of Matt Wiebe's SD_Register_Post_Type class
* http://somadesign.ca
*
* @access public
* @return void
*/
function context_fixer()
{
global $wp_query;
if ( get_query_var( 'post_type' ) == $this->custom_post_type_name ) {
$wp_query->set('is_home', false);
if( ! is_single() && ! is_404() && ! is_feed() ) {
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$events_per_page = $this->options['bbevents-events-per-page'];
$offset = ( $events_per_page * $paged ) - $events_per_page;
$args = array(
'paged'=>$paged,
'posts_per_page'=> $events_per_page,
'post_type'=>$this->custom_post_type_name,
'offset' => $offset,
'meta_key'=> 'start-bbevents',
'orderby' => 'meta_value',
'order' => 'ASC'
);
query_posts($args);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment