Custom Post Type post ordering not working

I’m having a problem with entries for a custom post type not being ordered as expected inside a custom query:

<h4>Related projects</h4>

            <?php

                $rp_args = array(
                        'post_type' => 'work',
                        'post_status' => 'publish',
                        'orderby' => 'title',
                        'order' => 'ASC',
                        );


                $related_projects = new WP_Query($rp_args);
            ?>

            <ul>
                <?php 
                if($related_projects->have_posts()):
                while ($related_projects->have_posts()) : $related_projects->the_post();
            ?>
                <li><a href="https://wordpress.stackexchange.com/questions/8438/<?php the_permalink();?>"><?php the_title();?></a></li>
            <?php
               endwhile;
               endif;
            ?>
            </ul>

It’s supposed to just simply pull out a custom post type and order it by name – but the ordering isn’t working and I’m not sure why not.

It’s simply listing the posts in the order they appear in the WP admin.

Any thoughts on why my ordering isn’t kicking in? It finds the correct post type and number of posts I specify – just the ordering doesn’t seem to work.

2 Answers
2

Yep – I’m stupid.

Post Types Order plugin has an option (set by default) which overrides any ordering done in queries. Turn that off and the problem goes away.

Leave a Comment