Metabox Relationship Query Args

Support MB Relationships Metabox Relationship Query Args

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #40767
    metabox@webxdesign.studio[email protected]
    Participant

    Hi, struggling with what to enter in the query args fields of the UI for a relationship. I have a query which works well:

    	return [
        'post_type' => 'event',
        'posts_per_page' => '3',
        'orderby'   => 'meta_value',
        'meta_key'  => 'event_date',
        'order'     => 'ASC',
            'meta_query' => array(
                array(
                    'key' => 'event_date',
                    'compare' => '>=',
                    'value' => strtotime(date('Ymd', time()))
                  )
              )
    ];

    I can enter thesee as three individual key/value pairs in the UI:

        'orderby'   => 'meta_value',
        'meta_key'  => 'event_date',
        'order'     => 'ASC',
    

    and the sorting of what is returned is correct.

    I also need to add these args in so that only future events are returned:

            'meta_query' => array(
                array(
                    'key' => 'event_date',
                    'compare' => '>=',
                    'value' => strtotime(date('Ymd', time()))
                  )
              )
    

    how do I do that with query args in the UI? Many thanks.

    #40774
    PeterPeter
    Moderator

    Hello,

    You can follow the documentation below to add the query args in the builder but some PHP functions are not supported adding in the builder like strtotime(), date()
    https://docs.metabox.io/extensions/meta-box-builder/#dot-notation

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.