• I’m struggling to make two custom queries for visual composer:

    1. a query which will display posts which are published with a date after today’s date (have plugin which publishes future posts) in Ascending or descending order (whichever makes it show the soonest upcoming event first)

    2. a query which will display only posts which meet multiple category requirements (eg. categories ‘upcoming’ and ‘class’ or ‘upcoming’ and ‘social’

    Really, either of these should give me the results I want, but the first would be most convenient.

    I can’t for the life of me decipher the Codex’s page on custom queries and figure out how to get them to work outside of the context of a php page, and in the context of the visual compose.

    One thought I had is that perhaps I need to add a custom query to my functions.php that has a name, and then call the query with the variables from Visual Composer? Is that the right ideas?

    I’ve tried the following to satisfy #1 and it seems to have disregarded the query altogether and just displayed all the events:
    [vc_basic_grid post_type=”custom” grid_id=”vc_gid:1473741223498-3776c0d3-292b-4″ custom_query=”WP_Query( ”showposts=20&monthnum=’ . date_query( array( ‘after’, . NOW() . ) ) . ‘&order_by=date&order=DESC’)”]

    [vc_separator]

    [vc_basic_grid post_type=”custom” grid_id=”vc_gid:1473741223504-67e7758b-8892-6″ custom_query=”$args = array(
    ‘date_query’ => array(
    array(
    ‘after’ => NOW(),
    ‘inclusive’ => true,
    ),
    ),
    ‘posts_per_page’ => -1, ‘order_by’ => ‘date’, ‘order’ => ‘ASC’
    );
    $query = new WP_Query( $args );”]

    Would love some nudges in the right direction!

  • The topic ‘Custom Queries with Visual Composer’ is closed to new replies.