Support

Account

Home Forums Front-end Issues What's wrong with this Query

Helping

What's wrong with this Query

  • `<?php
    $events = array (
    ‘tag_name’ => ‘oldevents’,
    ‘posts_per_page’ => ‘9’,
    ‘post__not_in’ => get_option(‘sticky_posts’),
    ‘order’ => ‘DESC’,
    ‘meta_query’ => array(
    array(
    ‘key’ => ‘event_date’,
    ‘orderby’ => ‘meta_value_num’,

    ),
    ),
    );

    // The Query
    $the_query = new WP_Query($events);
    ?>`

    I am trying to select posts both two values one being tags marked “oldevents” and also by ACF is_event T/F field and also order by date date picker field.

  • Hi @melissaspiegel,

    Thanks for the post.

    I believe you will need to add the meta_query for the ‘is_event’ custom field and comment out the meta_query that you have.

    Your code should ultimately look like so:

    <?php
    $events = array (
    ‘tag_name’ => ‘oldevents’,
    ‘posts_per_page’ => ‘9’,
    ‘post__not_in’ => get_option(‘sticky_posts’),
    ‘orderby’ => ‘meta_value_num’,
    'meta_key' => 'event_date',
    'order' => 'ASC',
    
    );
    
    // The Query
    $the_query = new WP_Query($events);
    ?>
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘What's wrong with this Query’ is closed to new replies.