[wp-trac] [WordPress Trac] #21522: Custom posts query does not work on index with paged var
WordPress Trac
wp-trac at lists.automattic.com
Mon Aug 13 09:59:04 UTC 2012
#21522: Custom posts query does not work on index with paged var
--------------------------+------------------------------
Reporter: adrian7 | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 3.4
Severity: normal | Resolution: fixed
Keywords: close |
--------------------------+------------------------------
Changes (by adrian7):
* status: new => closed
* resolution: => fixed
Comment:
Thanks @ocean90 it worked like a charm. Here's the code I used:
{{{
function nm_index_query( $query ){
$paged = intval( get_query_var('paged') );
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'post_type', array('post', 'movie',
'director', 'actor'));
$query->set( 'paged', $paged);
}
}
add_action( 'pre_get_posts', 'nm_index_query' );
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21522#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list