Posts 2 Posts
[resolved] Relationship meta order by (4 posts)

  1. aaron@rossano.com.au
    Posted 3 years ago #

    I'm trying to order my relationship results with a meta value I've set in my relationship called featured. I've looked around the forum and couldn't find the answer.

    I'd also like to be able to order it by date as well, is that possible to add in a second condition or meta?

    sample code:
    p2p_type( 'obj_to_obj2' )->each_connected( $my_query, array('orderby'=>'featured', 'order'=>'DESC','connected_order_num' => true), 'obj' );


  2. Manny Fleurmond
    Posted 3 years ago #

    Is it a regular meta or a connection meta. If it's the later, then:

    p2p_type( 'obj_to_obj2' )->each_connected( $my_query, array('connected_orderby'=>'featured', 'connected_order'=>'desc','connected_order_num' => true), 'obj' );

  3. aaron@rossano.com.au
    Posted 3 years ago #

    that worked. thank you funkatronic!.
    am i able to also combine the featured condition with the date of the posts as secondary order condition?

  4. scribu
    Plugin Author

    Posted 3 years ago #

    In the development version (1.4.3-alpha), the field specified via 'orderby' is added to the ORDER BY clause in the query, after the 'connected_orderby' field.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Posts 2 Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic