1全文检索文章分类过滤问题:
全文检索在index.php里面 使用form提交给query函数所以用php 函数设定参数无效,可以使用inut进行设定
比如对类别进行限定:
<input name="cat" type="hidden" value="1" /> <!--表示对cat id 为1的所在分类下的文章进行选取-->
<input name="cat" type="hidden" value="-1" /> <!--表示对cat id 为1的所在分类下的文章进行过滤-->
<input name="cat" type="hidden" value="-1,-2" /> <!--表示对cat id 为1,还有-2的所在分类下的文章进行过滤-->
2全文检索文章类型过滤问题:
<input name="post_type" type="hidden" value="post" /> <!--表示对post_type 为posts表中文章类型的内容进行选取-->
以此类推可以根据一下参数对筛选条件进行调整,以此达到合适的需求
<?php
$args = array(
//作者参数 - Show posts associated with certain author.
//http://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters
'author' => '1,2,3,', //(int) - use author id [use minus (-) to exclude authors by ID ex. 'author' => '-1,-2,-3,']
'author_name' => 'luetkemj', //(string) - use 'user_nicename' (NOT name)
'author__in' => array( 2, 6 ), //(array) - use author id (available with Version 3.7).
'author__not_in' => array( 2, 6 ), //(array)' - use author id (available with Version 3.7).
//类别参数 - Show posts associated with certain categories.
//http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters
'cat' => 5,//(int) - use category id.
'category_name' => 'staff, news', //(string) - Display posts that have these categories, using category slug.
'category_name' => 'staff+news', //(string) - Display posts that have "all" of these categories, using category slug.
'category__and' => array( 2, 6 ), //(array) - use category id.
'category__in' => array( 2, 6 ), //(array) - use category id.
'category__not_in' => array( 2, 6 ), //(array) - use category id.
//标签参数 - Show posts associated with certain tags.
//http://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters
'tag' => 'cooking', //(string) - use tag slug.
'tag_id' => 5, //(int) - use tag id.
'tag__and' => array( 2, 6), //(array) - use tag ids.
'tag__in' => array( 2, 6), //(array) - use tag ids.
'tag__not_in' => array( 2, 6), //(array) - use tag ids.
'tag_slug__and' => array( 'red', 'blue'), //(array) - use tag slugs.
'tag_slug__in' => array( 'red', 'blue'), //(array) - use tag slugs.
//分类参数(自定义分类法) - Show posts associated with certain taxonomy.
//http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters
//Important Note: tax_query takes an array of tax query arguments arrays (it takes an array of arrays)
//This construct allows you to query multiple taxonomies by using the relation parameter in the first (outer) array to describe the boolean relationship between the taxonomy queries.
'tax_query' => array( //(array) - use taxonomy parameters (available with Version 3.1).
'relation' => 'AND', //(string) - Possible values are 'AND' or 'OR' and is the equivalent of running a JOIN for each taxonomy
array(
'taxonomy' => 'color', //(string) - Taxonomy.
'field' => 'slug', //(string) - Select taxonomy term by ('id' or 'slug')
'terms' => array( 'red', 'blue' ), //(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'.
),
array(
'taxonomy' => 'actor',
'field' => 'id',
'terms' => array( 103, 115, 206 ),
'include_children' => false,
'operator' => 'NOT IN'
)
),
//文章和页面参数 - Display content based on post and page parameters.
//http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters
'p' => 1, //(int) - use post id.
'name' => 'hello-world', //(string) - use post slug.
'page_id' => 1,