I have a page template that, firstly, has a loop towards the top in order to display a list of links to testimonial custom posts (I'm using a plugin to re-order posts):

<?php query_posts('post_type=testimonial&posts_per_page=-1&orderby=menu_order&order=ASC'); ?>
    <?php get_template_part('loop', 'testimonials-thumbs' ); ?>
<?php wp_reset_query(); ?>

So I can get the above to display in the correct order using the query above. But I'm struggling to order the posts for the loop I have further down that displays the content of each testimonial.

<?php get_template_part('loop', 'testimonial-single' ); ?>

So the testimonial contents display in the order that the posts were added to WordPress (I think), unlike the list of testimonial links above that display in the custom menu order.

As well as that, I have next / previous links like so:

<?php if ($nextPost->ID) : ?>
    <a class="prev" href="<?php echo get_permalink($nextPost->ID); ?>"></a>
<?php endif; ?>
<?php if ($prevPost->ID) : ?>
    <a class="next" href="<?php echo get_permalink($prevPost->ID); ?>"></a>
<?php endif; ?>

But again, I need to order these by menu_order.

I have tried modifying the query like so:

<?php query_posts('orderby=menu_order&order=ASC'); ?>
    <?php get_template_part('loop', 'testimonial-single' ); ?>
<?php wp_reset_query(); ?>

But that appears to just break the loop and none of the content displays.

  • What does the loop before get_template_part('loop', 'testimonial-single' ); look like? Also, how are you setting $nextPost and $prevPost? It would be helpful if you could include the entire template in your question. – Dave Romsey Jun 11 '17 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.