WordPress按自定义分类法查询

时间:2015-02-20 10:35:33

标签: php wordpress

尝试根据搜索结果执行自定义查询,结果未通过。我查看了我的代码,看起来是对的:

$args = array(
            'post_type' => 'images',
            'post_status'   =>  'publish',
            'posts_per_page'    =>  10,
            'paged'         =>  $paged,
            's'             =>  $state,
            'tax_query' => array(                     //(array) - use taxonomy parameters (available with Version 3.1).
              array(
                'taxonomy' => 'type',                //(string) - Taxonomy.
                'field' => 'slug',                    //(string) - Select taxonomy term by ('id' or 'slug')
                'terms' => array( 'first-images', 'second-images' ),    //(int/string/array) - Taxonomy term(s).
                'include_children' => true,           //(bool) - Whether or not to include children for hierarchical taxonomies. Defaults to true.
                'operator' => 'IN' 
                )                   //(string) - Operator to test. Possible values are 'IN', 'NOT IN', 'AND'.
              ),
            ); 

            $search = new wp_query( $args ); ?>

感谢您的帮助。

0 个答案:

没有答案