meta_query在wp_query中不起作用

use*_*609 2 php mysql wordpress printf wp-query

我的帖子类型是product.当我是数组([0] =>精选)时,我使用带有meta keyis ht_featured,meta值的复选框字段print_r.
我的WP_Query:

$the_query = new WP_Query(
    'post_type'     => 'product',
    'showposts'     => 12,
    'meta_query'    => array(
            array(
                    'key'       => 'ht_featured',
                    'value'     => array('featured'),
                    'compare'   => 'IN'
            )
    )
);
Run Code Online (Sandbox Code Playgroud)

它没有显示任何帖子.我尝试过value => 'featured','compare' => 'EXISTS'但它不起作用.

小智 5

WP_query需要在数组中传递.使用以下代码,让我知道是否有任何问题.

$the_query = new WP_Query (array (
        'post_type'     => 'product',
        'showposts'     => 12,
        'meta_query' => array(
            array(
                'key'       => 'ht_featured',
                'value'     => array('featured'),
                'compare'   => 'IN'
            )
        )
    ));
Run Code Online (Sandbox Code Playgroud)

你可以参考wordpress论坛上的讨论:

http://wordpress.org/support/topic/how-to-wp_query-meta_query-value-string-contain-in-key-string
Run Code Online (Sandbox Code Playgroud)