用wordpress 开发了一个网站。现在搜索页面里搜索到全部内容,但我网站里有些内容不想让出现搜索页面,请问怎么做?
不想搜索到的内容,我是用自定义内容创建的~
比如,我用 wordpress 自定义内容建了一个客户的栏目
但客户里内容,我不想在搜索页面里被搜索到。怎么做?
问题不明确,没人可以回答你具体的内容。
你自己去搜索下WordPress的query参数吧。
if ( !is_admin() ) { function searchfilter($query) {
//限定对搜索查询和非后台查询设置 if ($query->is_search && !is_admin() ) {$query->set('post_type',array('post', 'news', 'case', 'page')); } return $query; } add_filter('pre_get_posts','searchfilter'); }
解决了~
在function里面加一个过滤函数:
function check_page() {
global $post;
return ($post->post_type == 'customer')?true:false;
}
之后在search.php中加一段判断
<?php
if (check_page()) continue;
?>
使用全局变量$post来过滤具体看情况
http://www.hank-chan.com/blog/?p=36