Question

I've got the following loop on my index.php template:

<div id="new_on">

            <?php 
            $args = array( 
                'meta_query' => array(
                    'meta_key' => 'is_url', 
                    'meta_value' => 'yes', 
                    'meta_compare' => 'NOT LIKE'
                ),
            );

            $main_query = new WP_Query( $args );
            while ( $main_query->have_posts() ) : $main_query->the_post();
            ?>

            <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
            <div class="clearfix smalltext"><span class="left"><a href="<?php the_author_link(); ?>"><?php the_author(); ?></a></span><span class="right"><?php echo the_time(); ?></span></div>
            <?php the_excerpt(); ?>

            <?php endwhile; wp_reset_postdata(); ?>

            </div>

The query should return all posts that do not have the custom field 'is_url' set to 'yes'. It is returning all posts, regardless of the value of is_url. I usually use Custom Post Types for this sort of thing, so I haven't used the meta_query too extensively. Anybody know what I'm doing wrong?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top