Search a meta field for a value in all posts
WP_Query will return a WP_Query object. An object will never match the string $ip that you are comparing it to. What you need to be doing is checking whether results were returned, which you can do by checking the found_posts property: $ip = $_SERVER[‘REMOTE_ADDR’]; $query = new WP_Query( array( ‘ignore_sticky_posts’ => true, ‘meta_key’ => ‘voted_IP’, … Read more