how can i use custom field in query post

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

I tried bellow,but it failed

Read More
$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

EDIT:

$arg2 = array(
    'posts_per_page'=>'5',
    'cat'=>'3',
    'orderby'=>'rand',
    'meta_query'=> array(
        'key'=>'Featured List',
        'value'=>'Yes',
        'compare'=>'LIKE'
    )
);

$featured_random_item = new WP_Query($arg2);

This query also failed.

How can i do this

Thanks in advance !

Related posts

Leave a Reply

2 comments

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

    $args = array(
        'posts_per_page' => '5',
        'cat' => '3',
        'orderby' => 'rand',
        'meta_query' => array(
    
            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.