Support

Account

Home Forums General Issues wp_query based on select dropdown

Unread

wp_query based on select dropdown

  • Hi,

    I have used a field (multiple select) called ‘Role’ for each post. I have created a page that should have all the post based on two select values of Role(‘Data-Steward’, ‘IT-Engineering’)
    I know I have only 2 such posts. But I am getting back 11 posts. Here is my code.

    <?php
    $args = array(
    'post_type' => 'post',
    'post_status' => 'publish',
    'meta_query' => array(
    'relation'		=> 'OR',
    array(
    'key'     => 'role',
    'value'   => 'Data-Steward',
    'compare' => 'LIKE',
    array(
    'key'     => 'role',
    'value'   => 'IT-Engineering',
    'compare' => 'LIKE',
    )
    )
    );
    $the_query = new WP_Query( $args );
    ?>
    <?php if ($the_query->have_posts()) : ?>
    <?php while ($the_query->have_posts()) : $the_query->the_post(); ?>

    Am I doing something wrong here? Please help me fix this.

Viewing 1 post (of 1 total)

The topic ‘wp_query based on select dropdown’ is closed to new replies.