Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save carlaizumibamford/ba7b5fc210c184c903e192785c22159d to your computer and use it in GitHub Desktop.
Save carlaizumibamford/ba7b5fc210c184c903e192785c22159d to your computer and use it in GitHub Desktop.
Display only pages:
$query = new WP_Query( array( 'post_type' => 'page' ) );
Display ‘any‘ post type (retrieves any type except revisions and types with ‘exclude_from_search’ set to TRUE):
$query = new WP_Query( array( 'post_type' => 'any' ) );
Display multiple post types, including custom post types:
$args = array(
'post_type' => array( 'post', 'page', 'movie', 'book' )
);
$query = new WP_Query( $args );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment