Convert wp_query arguments into query string for Visual Composer Post Grid

722 Views Asked by At

I have a wp_query which is as follows:

$the_query = new WP_Query( array(
'post_type' => 'Session',
'meta_query' => array(
    'relation' => 'AND',
    'track_clause' => array(
        'key'     => 'track',
        'compare' => 'EXISTS',
    ),
    'start_date_clause' => array(
        'key'     => 'start_date_and_time',
        'compare' => 'EXISTS',
        'type' => 'DATETIME',
    ), 
    'zoom_clause' => array(
        'key'     => 'zoom_recording_link',
    'value'   => '',      
    'compare' => '!=', 
    ),
),
     'orderby' => array( 
    'start_date_clause' => 'ASC',
    'track_clause' => 'ASC',
),
'posts_per_page' => '-1',
));

However, I now want to use this query with the Wp Bakery Visual Composer Post Grid which essentially requires me to represent this code above as query strings in a URL

To try and get this to work, I put the following in as the URL

post_type=session&post_status=publish&posts_per_page=-1&meta_query[relation]=and&meta_query[0]=track_clause&meta_query[0][key]=track&meta_query[0][compare]=EXISTS&meta_query[1]=start_date_clause&meta_query[1][key]=start_date_and_time&meta_query[1][compare]=EXISTS&meta_query[1][type]=DATETIME&meta_query[1]=zoom_clause&meta_query[2][key]=zoom_recording_link&meta_query[2][value]=''&meta_query[2][compare]=!=&orderby[0][start_date_clause]=ASC&orderby[1][track_clause]=ASC

However, while the ordering works, it's showing ALL the posts which is not what I'm expecting. I presume there is an issue with my URL? Could anyone offer some guidance?

1

There are 1 best solutions below

0
On BEST ANSWER

I sorted this now. I found this https://sandbox.onlinephpfunctions.com/code/5c2bc6ddd37a02fc8facf4f227176e262854b92e which just allowed me to convert my query into a URL