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? 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! 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

2 Answers 2

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.

0

Just in case anyone is look for an answer to solve this - just head into the plugin settings (for the Post Types Order plugin) and UNCHECK the setting that says "apply order sort".

This will still allow you to sort by menu order and re-order the items if needed, but doesn't force/override any other settings.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.