Tint主题开启全局搜索
本设置为适应网站导航,全局共用导航后导致其它文章类型搜索失败
网上找的代码在Tint中会导致搜索页导航无效,代码如下:
function include_post_types_in_search($query) {
if(is_search()) {
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false), 'objects');
$searchable_types = array();
if($post_types) {
foreach( $post_types as $type) {
$searchable_types[] = $type->name;
}
}
$query->set('post_type', $searchable_types);
}
return $query;
}
add_action('pre_get_posts', 'include_post_types_in_search');
如何在Tint主题中正常使用呢?
更改如下,首先
更改vm.Search.php
中
此处内容需要 登录 加入VIP会员可见
教程到此结束!