Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
If there's an error - I'm not seeing it, looks correct to me. Are you sure you're not cached? –  Howdy_McGee Apr 23 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. –  bestprogrammerintheworld Apr 23 at 21:28
1  
You should post this as an answer, so this question doesn't go unanswered for eternity! –  Howdy_McGee Apr 23 at 21:48
    
done. I have to wait 2 days before I can accept my own answer though... –  bestprogrammerintheworld Apr 23 at 21:54

1 Answer 1

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.

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.