Last active
October 6, 2019 10:22
-
-
Save jessuppi/b6aff0eb4c8b7cb10f36fb3387bedda6 to your computer and use it in GitHub Desktop.
Different Ways to Query WordPress Posts
This file contains 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
<?php | |
$options = array( | |
'post_type' => 'person', | |
'posts_per_page' => 99, | |
'orderby' => 'date', | |
'order' => 'ASC', | |
'paged' => $paged, | |
); | |
$query = new WP_Query( $options ); | |
if ( $query->have_posts() ) : | |
while($query->have_posts()) : $query->the_post(); | |
the_title(); | |
endwhile; wp_reset_query(); | |
endif; | |
?> | |
<?php | |
$args = array ('post_type' => 'person', 'posts_per_page' => 15, 'orderby' => 'recent','order' => 'DSC'); | |
query_posts($args); | |
if (have_posts()) : while (have_posts()) : the_post(); ?><div class="story-box"> | |
<div class="story-slug"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></div> | |
<a href="<?php the_permalink() ?>"><img class="image" src="" alt=""></a> | |
<div class="excerpt"></div> | |
</div><!-- end story-box --> | |
<div class="clear-zero"></div> | |
<?php endwhile; endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reserving the first comment.