WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a page on my site that has customer testimonials. Each testimonial is a custom post. I want to order the testimonials arbitrarily. What's the best way to do this?

share|improve this question
up vote 0 down vote accepted

The way I previously did this, was by adding a custom field to my CPTs, and ordering by that value when I fetched my posts with WP_Query.

 $myquery = new WP_Query( array(
      'post_type' => 'your_post_type',
      'meta_key' => 'my_custom_field_name',
      'orderby' => 'meta_value'
      )
 );

However, I believe if you add 'page-attributes' to your 'supports' parameter when you register your CPT, you have the 'Order' field available, which you can order by.

 $myquery = new WP_Query( array(
      'post_type' => 'your_post_type',
      'orderby' => 'menu_order'
      )
 );
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.