Skip to:
Content
Pages
Categories
Search
Top
Bottom

Sorting by Custom Meta in Groups Loop Using Order By


  • otterly
    Participant

    @otterly

    I’ve run into a bit of a roadblock in my customization of the Groups page. I have created a custom ‘Order By’ drop down item and leveraged the ‘Group Meta Queries: Usage Example’ example posted here on BuddyPress to create a custom ‘Order By’ option based on a custom field (‘meta_key’ = ‘launch-date’) I created. Everything up until that point is working beautifully. I display only Groups with a populated ‘launch-date’ field.

    What I’d like to do is take it one step further. I’d like to take results and order them by the value in the ‘launch-date’ field in ascending order.

    I know this is possible via WP_Query so I’m hoping it’s possible in BuddyPress. 🙂

    Below is my code snippet. Hoping for a bit of input on where I may be going wrong.

    $launch_date_querystring[‘meta_query’] = array(
    array(
    ‘key’ => ‘launch-date’,
    ‘value’ => ”,
    ‘type’ => ‘date’,
    ‘compare’ => ‘!=’,
    ),
    ‘orderby’ => ‘meta_value’,
    ‘meta_key’ => ‘launch-date’,
    ‘order’ => ‘ASC’
    );

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Sorting by Custom Meta in Groups Loop Using Order By’ is closed to new replies.
Skip to toolbar