• Resolved Stefan

    (@stefan83)


    Hi – I’m using the following query to get posts on a page that have a specific custom field. It work fine but if I delete the value within the custom field on a post, that post is still pulled in. Any ideas how I can fix this? <?php query_posts('meta_key=speaker_video_code&orderby=title&order=asc&posts_per_page=-1'); ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • You can probably use this:

    query_posts('meta_key=speaker_video_code&meta_value=!&meta_compare=>&orderby=title&order=asc&posts_per_page=-1'); ?>

    That will get any non-empty meta_value other than a single exclamation mark.

    I think you can replace the exclamation mark with a single space to get any non-empty value, but I have not tested that.

    Thread Starter Stefan

    (@stefan83)

    Thanks vtxyzzy, that’s great!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get post with specific custom field problem’ is closed to new replies.