我使用的是themeforest.net中的Thallasa主题。这有点糟糕,但没关系,当我搜索并添加我的页面、帖子、项目项(显然是自定义帖子类型)时,搜索无法找到项目项。它查找项目页面,每隔一个页面或帖子,但不查找单个项目。
该网站http://sisgroup.webpandas.com/
提前谢谢。
将以下代码添加到您的functions.php中(将帖子类型修改为您的。
<?php
function filter_search($query) {
if ($query->is_search) {
$query->set('post_type', array('post', 'page', 'projects'));
}
return $query;
}
add_filter('pre_get_posts', 'filter_search');
?>