I've been working on this issue for several hours now and I'm stumped. The following query refuses to accept any orderby directive. NOTE: This is running on a single-cpt.php page within the normal WP Loop:

<?php $args = array(
  'orderby' => 'title',
      'order' => 'ASC',
  'suppress_filters' => true,
  'nopaging' => true,
  'connected_type' => 'directory_to_projects',
  'connected_items' => get_queried_object_id(),

$new_connected = new WP_Query($args);

// Display connected posts
if ( $new_connected->have_posts() ) { ?>

        <?php while ( $new_connected->have_posts() ) : $new_connected->the_post(); ?>
            <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
        <?php endwhile; 
        wp_reset_postdata(); ?>
<?php } ?>

I've confirmed I'm not running any page- or post-ordering plugins that might interfere with 'orderby'. Switching 'orderby' to something else (name, date, meta_value, you name it) has no effect whatsoever.

UPDATE: Actually, no parameters for wp_query are working at all. I tried adding 'posts_per_page' => 2, and that had no effect either. Must be a posts2posts thing but I believe support for that plugin has been discontinued. :( Anyone ever run into this?

Any ideas? Thanks so much for your help!

  • If you deactivate the Posts2posts plugin, does the query return the correct posts? Commented Aug 14, 2013 at 21:12

1 Answer 1


I don't have any experience with posts2posts, but to see the query that wp_query runs on your database, before your if statement, put echo $new_connected->request. Helped me a lot to debug wp_query when I couldn't find out which parameters weren't working. The output is the SQL query that will be performed on the DB. Therefor you can copy this query in phpmyadmin to see the results. Maybe it will help you gain more insight into the problem!

PS using 'orderby' => 'meta_value' requires 'meta_key' => 'your_metakey_name' else it doesn't know which key to get the value from to sort by.

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.