WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to get all featured items using query post. featured is meta_key using custom field plugin.

I tried bellow,but it failed

$featured_item = new WP_Query('posts_per_page=-1&cat=3&meta_key=>Featured List&meta_value=>Yes');

my wp version is 3.1.3


$arg2 = array(
    'meta_query'=> array(
        'key'=>'Featured List',

$featured_random_item = new WP_Query($arg2);

This query also failed.

How can i do this

Thanks in advance !

share|improve this question
up vote 2 down vote accepted

Your meta_query needs to be a nested array, like so;

$args = array(
    'posts_per_page' => '5',
    'cat' => '3',
    'orderby' => 'rand',
    'meta_query' => array(

            'key' => 'Featured List',
            'value' => 'Yes'        

And I get the feeling you don't actually need a LIKE match - this'll perform a loose comparison, and isn't as efficient as an exact match.

share|improve this answer

The documentation for WP_Query is here: http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters

You should use the array syntax, as it will make things clearer for you.

share|improve this answer
will you explain with examples? already i saw that class reference page but am not getting idea,how to solve this !! – Ramkumar Jun 29 '11 at 11:03
Thanks for the respomse, I tried that query,but still it fails. look at my edit,There is what i tried . can you tell me whats wrong in query. – Gowri Jun 29 '11 at 11:53
@ramkumar - there are examples on the Codex page. – anu Jun 29 '11 at 12:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.