Skip to content

Instantly share code, notes, and snippets.

@jkudish
Created October 5, 2011 05:36
Show Gist options
  • Save jkudish/1263730 to your computer and use it in GitHub Desktop.
Save jkudish/1263730 to your computer and use it in GitHub Desktop.
Modify a query to show an archive of CPTs
<?php
add_action('pre_get_posts', 'ipstenu_pre_get_posts');
function ipstenu_pre_get_posts($query){
if ($query->is_page('name-of-your-page')) { // any and all conditionals work here as a method of the $query object
$query->set('post_type', 'video'); // use the set method as if you were using a regular WP_Query or query_posts etc...
$query->set('posts_per_page', 10);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment