• I’m trying to get all posts that have the meta_key ‘imgs’ AND have a meta_value for ‘imgs’ that is not nothing. I’ve tried meta_value = (with nothing following it as seen below), meta_value=False, meta_value=false, meta_value=empty and meta_value=0. Nothing works. I keep getting back posts that have a blank value for the custom field: ‘imgs’. Thanks in advance!

    <?php query_posts('&meta_key=imgs&meta_compare=!=&meta_value=&orderby=rand&showposts=10'); if (have_posts()) : while (have_posts()) : the_post(); ?>

Viewing 1 replies (of 1 total)
  • Thread Starter Tom Von Lahndorff

    (@tomvon)

    Ha! I just figured it out. My fields were not blank but contained a single space for fields that were blank. Seem the code I used was right I just had to change it to:

    <?php query_posts('&meta_key=imgs&meta_compare=!=&meta_value= &orderby=rand&showposts=10'); if (have_posts()) : while (have_posts()) : the_post(); ?>

    for it to work. Hooray!

Viewing 1 replies (of 1 total)
  • The topic ‘query_posts if meta_value != ”’ is closed to new replies.