0

I have a custom post type called personnel

Look at this code:

$args = array( 'post_type' => 'personnel', 
               'posts_per_page' => -1,  
              );
$personnel_query = new WP_Query( $args );

Above works fine but I wanted the posts to be sorted alphabetically. I tried this:

$args = array( 'post_type' => 'personnel', 
               'posts_per_page' => -1,  
               'orderby' => 'title', 
               'order' => 'ASC'
              );
$personnel_query = new WP_Query( $args );

But it doesn't have any effect on the sorting. I tried both ASC and DESC for the order-attribute.

What am I doing wrong?

4
  • If there's an error - I'm not seeing it, looks correct to me. Are you sure you're not cached?
    – Howdy_McGee
    Commented Apr 23, 2014 at 21:24
  • I just figured it out. It's a plugin called Post Types Order that is ovverriding the WP_Query functionality somehow which makes the admin able to sort different post/categories etc. Commented Apr 23, 2014 at 21:28
  • 1
    You should post this as an answer, so this question doesn't go unanswered for eternity!
    – Howdy_McGee
    Commented Apr 23, 2014 at 21:48
  • done. I have to wait 2 days before I can accept my own answer though... Commented Apr 23, 2014 at 21:54

1 Answer 1

2

In case someone else happens to stumble upon an issue like this:

I'm using a plugin called Post Types Order (https://wordpress.org/plugins/post-types-order/) that is somehow "overriding" the sorting-mechanism of WP_Query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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