查询帖子时,只需使用普通循环,并向其传递一组参数。然后在最后重置查询。
<?php
// makes query respect paging rules
$paged = get_query_var(\'paged\');
// defining the arguements for the custom loop
$variablenameQuery = array(
\'post_type\' => \'seating-charts\',
\'post_status\' => \'publish\',
\'cust_tax_name\' => \'custom-tax-term\',
\'posts_per_page\' => -1, // neg 1 means all posts
\'orderby\' => \'date\',
\'order\' => \'ASC\',
\'paged\' => $paged,
); // end query
// pass result into query_posts to get result
query_posts($variablenameQuery);
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php // Individual Post Styling ?>
<?php endwhile; ?>
<?php // paged navigation - next post, previous post... ?>
<?php else : ?>
<h3>Ooops looks like there was an issue. Please <a href="<?php echo get_option(\'home\'); ?>/contact" title="Contact Us">get in touch</a> with us and we\'ll get the problem fixed.</h3>
<?php endif; ?>
<!-- resets the WordPress Query -->
<?php wp_reset_query(); ?>