Created
November 9, 2010 15:49
-
-
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]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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