Find post of author with meta_key - Wordpress

1k views Asked by At

This's my query:

$list = query_posts(array(
    'post_type' => 'post',
    'author' => $current_user->ID,
    'category__in' => array(11),
));

It ok, but when I change it to:

$list = query_posts(array(
    'post_type' => 'post',
    'author' => $current_user->ID,
    'category__in' => array(11),
    'meta_key' => 'author_alias_id',
    'meta_value' => '1'
));

The result is empty.

Somebody can help me?

1

There are 1 answers

2
Domain On
$args = array(
    'post_type'  => 'my_custom_post_type',
    'meta_key'   => 'age',
    'orderby'    => 'meta_value_num',
    'order'      => 'ASC',
    'meta_query' => array(
        array(
            'key'     => 'age',
            'value'   => array( 3, 4 ),
            'compare' => 'IN',
        ),
    ),
);

Refer this example