Php 按自定义分类法进行WordPress查询
尝试基于搜索结果执行自定义查询,但结果未通过。我查看了我的代码,它似乎是正确的:Php 按自定义分类法进行WordPress查询,php,wordpress,Php,Wordpress,尝试基于搜索结果执行自定义查询,但结果未通过。我查看了我的代码,它似乎是正确的: $args = array( 'post_type' => 'images', 'post_status' => 'publish', 'posts_per_page' => 10, 'paged' => $paged, 's'
$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 ); ?>
谢谢您的帮助。您能提供更多调试详细信息吗?$state和$paged是否可用,它们是否有有效的结果?$search的var_dump是什么?这些术语真的是复数吗?例如,术语“first images”还是“first images”?$state只是一个普通的$GET['state],而$paged是从codex中提取的,我在同一个网站上使用过无数次。这不会是影响上述情况的问题。