Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 搜索功能,还可以在帖子的自定义字段中搜索关键字_Wordpress_Search_Advanced Custom Fields - Fatal编程技术网

Wordpress 搜索功能,还可以在帖子的自定义字段中搜索关键字

Wordpress 搜索功能,还可以在帖子的自定义字段中搜索关键字,wordpress,search,advanced-custom-fields,Wordpress,Search,Advanced Custom Fields,wp中的默认搜索功能仅搜索帖子/页面的内容。但是我有一些分类,上面有自定义字段的帖子(我使用了高级自定义字段插件),我尝试使用许多插件作为relevansi,但仍然没有找到在自定义字段中搜索的方法。也许我错过了什么。如何获得包含自定义字段的搜索结果?请帮忙。像这样试试 function custom_search_where($where) { // put the custom fields into an array $customs = array('custom_field1', 'cu

wp中的默认搜索功能仅搜索帖子/页面的内容。但是我有一些分类,上面有自定义字段的帖子(我使用了高级自定义字段插件),我尝试使用许多插件作为relevansi,但仍然没有找到在自定义字段中搜索的方法。也许我错过了什么。如何获得包含自定义字段的搜索结果?请帮忙。

像这样试试

function custom_search_where($where) {
// put the custom fields into an array
$customs = array('custom_field1', 'custom_field2', 'custom_field3');

foreach($customs as $custom) {
$query .= " OR (";
$query .= "(m.meta_key = '$custom')";
$query .= " AND (m.meta_value  LIKE '{$n}{$term}{$n}')";
    $query .= ")";
}

$where = " AND ({$query}) AND ($wpdb->posts.post_status = 'publish') ";
return($where);
}
add_filter('posts_where', 'custom_search_where');

你能展示你的实现代码吗?@BindiyaPatoliya实际上我的意思是wp中的默认搜索,它在帖子内容中搜索查询……Sorry会尝试让你知道。谢谢。:)