Created
October 14, 2012 21:03
-
-
Save chrisdigital/3889811 to your computer and use it in GitHub Desktop.
Using wp_query to pull all entries under a custom post type
This file contains hidden or 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
<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