0

Using WP-Query, I'm setting the Orderby parameter using an array:

$events_args = array(
    'post_status' => 'publish',
    'post_type' => 'events',
    'meta_key' => 'start_time',
    'meta_type' => 'DATETIME',
    'orderby' => array( 'meta_value_num' => 'DESC', 'title' => 'ASC' ),
    'order' => 'ASC',
    'posts_per_page'    => -1,
    'meta_query' => array(
        array(
            'key'       => 'event_date',
            'compare'   => '=',
            'value'     => 20150225,
        )
      )
);

I need to filter the first item in the array (meta_value_num). Using add_filter , how can I access the first item of the Orderby array to make the adjustments I need?

Thank you!

1
  • I think pre_get_posts will help you. Commented Jan 16, 2015 at 20:54

1 Answer 1

0

Thanks karpstrucking,

This was a simple case of me needing to understand the Query better. Once I fully understood that wp_query returns a string for the sql query, it was a simply case of doing what I needed to do to correction the event_date value, concatenating on the additional title or meta_num_value and returning that.

Then I would just have to add_filter the orderby.

1
  • You can post your working code as an EDIT to your answer and accept your own answer. Commented Feb 13, 2015 at 0:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.