WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. aaron@rossano.com.au
    Member
    Posted 1 year 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' );

    http://wordpress.org/extend/plugins/posts-to-posts/

  2. Manny Fleurmond
    Member
    Posted 1 year 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
    Member
    Posted 1 year 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
    Member
    Plugin Author

    Posted 1 year 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

About this Topic