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)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.