Skip to content

Instantly share code, notes, and snippets.

@jessuppi
Last active October 6, 2019 10:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jessuppi/b6aff0eb4c8b7cb10f36fb3387bedda6 to your computer and use it in GitHub Desktop.
Save jessuppi/b6aff0eb4c8b7cb10f36fb3387bedda6 to your computer and use it in GitHub Desktop.
Different Ways to Query WordPress Posts
<?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; ?>
@jessuppi
Copy link
Author

jessuppi commented Oct 6, 2019

Reserving the first comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment