Looper: Custom Query String


I am generating a custom query string utilizing a custom post type and fields from Toolset. The code

$meta_query[] = array(
    'key'     => 'wpcf-start-date',
    'value'   => date('Ymd'),
    'compare' => '>=',
    'type' => 'DATE',

$query = array(
    'post_type'  => 'event-detail',
    'meta_key'   => 'wpcf-start-date',
    'orderby'    => 'meta_value',
    'order'      => 'ASC',
    'meta_query' => $meta_query,
    'posts_per_page' => 3

var_dump( http_build_query( $query ) );	

generates the following string


I am substituting the date “20211120” with {{dc:global:date format=“Ymd”}}

I have a similar string working on other sites but this one will not whereby a simple string such as

works fine but does not yield the desired result. Any ideas on what I am doing wrong?

Thank you for any suggestions you can share!


Hello Michael,

Thanks for writing in!

Change the "compare" => ">=" into just "compare" => ">" making the query return any event details that the start date will be starting from tomorrow.

See how it goes. If it does not return anything, please provide us access to the site so that we can check your event details and other settings. You can create a secure note in your next reply with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role
- Confirmation that we can access and make changes to your site

To know how to create a secure note, please check this out: How The Forum Works


Hi Michael,

In comparing dates, the orderby value should be meta_value_num and the type should be numeric. Your meta query should look like this one.

$today = date('Ymd');
$homepageEvents = (
'posts_per_page' => 3,
'post_type' => 'event-detail',
'meta_key' => 'wpcf-start-date',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'meta_query' => array(
    'key' => 'wpcf-start-date',
    'compare' => '>=',
    'value' => '$today,
    'type' => 'numeric'

Hope that helps build your query and let us know how it goes.

Thank you! I updated it, but no go. ;-( It is till oddly not bringing in the latest three events for May 2022.

Hey Michael,

It seems that the Toolset field doesn’t work with our meta query because the query you added is working when I replace it with an ACF field. Here are the things I have tested and it is working.

  • Install the ACF plugin
  • Create Event Start Date field and assign to Event Details Page
  • Choose 3 Event details ( The Matrix of Ashtanga Yoga, Anatomy of Backbends, Three Anatomical Points to Effortless Practice ) and add a future date
  • Then in the query, I just change the value wpcf-start-date to event_start_date and the full code is post_type=event-detail&meta_key=event_start_date&orderby=meta_value_num&order=ASC&meta_query%5B0%5D%5Bkey%5D=event_start_date&meta_query%5B0%5D%5Bvalue%5D={{dc:global:date format="Ymd"}}&meta_query%5B0%5D%5Bcompare%5D=%3E%3D&meta_query%5B0%5D%5Btype%5D=numeric&posts_per_page=3

And when you check your upcoming event page, it is showing the right data.

That being said, I suggest that you change the Toolset field just for the date to an ACF field. Please let us know if it is doable on your end.

Thank you.

I see, OK. god to know and thank you!!!

Hi Michael,

You’re welcome! If you have any other concerns or clarifications regarding our theme features, feel free to open up a new thread.

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.