Skip to content

Instantly share code, notes, and snippets.

@chrisdigital
Created October 14, 2012 21:03
Show Gist options
  • Save chrisdigital/3889811 to your computer and use it in GitHub Desktop.
Save chrisdigital/3889811 to your computer and use it in GitHub Desktop.
Using wp_query to pull all entries under a custom post type
<ul> <?php
$args3 = array(
'post_type' => array( 'investigators' ), //set post type
'post_status' => 'publish', // only pull published
'field' => 'slug', //searching on slug field
'orberby' => 'name', //order by name *ignored if using custom order by plugin, set in admin*
'order' => 'DESC', //in descending order
'posts_per_page'=> '-1', //show all
//- - - - - - - - - - - - -
//'tax_query' => array(
//'relation' => 'OR',
//array(
//'taxonomy' => 'category',
//'field' => 'slug',
//'terms' => array( 'media coverage' )
//),
//array(
//'taxonomy' => 'post_tag',
//'field' => 'slug',
//'terms' => array( 'featured-our-research' )
//)
//)
);
$investigators_query = new WP_Query( $args3 );
if ( $investigators_query->have_posts() ) {
while ( $investigators_query->have_posts() ) {
$investigators_query->the_post();
/// do stuff here
echo'<li><a href="'; the_permalink(); echo'" rel="bookmark">'; the_title(); echo'</a></li>';
}
}
?></ul>
<?php wp_reset_postdata();?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment