admin管理员组文章数量:1122846
I want to add another filter box to my admin "pages" screen, let's call it search2.
I want to be able to filter the results that I searched to be limited to only pages that contains search2 in the post_content. I've added the box and I can get the input to my function, but I can't figure out what to change in the query. I want this to work in the admin page whether or not 's' is empty & I don't want it to change what's in the 's' field because I want these to be able to be two different strings.
I'm adding the filter to parse_query()
and my function looks like:
public function modifyFilterQuery($query){
global $pagenow;
$search2_filter = filter_input(INPUT_GET, 'search2_filter', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if (true === in_array($post_type, ['page', '', ''], true) && 'edit.php' === $pagenow) {
if (false === empty($search2_filter)) {
//What Should I do here? Something like:
//$query->set(?);
//?
}
}
return $query;
}
I want to add another filter box to my admin "pages" screen, let's call it search2.
I want to be able to filter the results that I searched to be limited to only pages that contains search2 in the post_content. I've added the box and I can get the input to my function, but I can't figure out what to change in the query. I want this to work in the admin page whether or not 's' is empty & I don't want it to change what's in the 's' field because I want these to be able to be two different strings.
I'm adding the filter to parse_query()
and my function looks like:
public function modifyFilterQuery($query){
global $pagenow;
$search2_filter = filter_input(INPUT_GET, 'search2_filter', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if (true === in_array($post_type, ['page', '', ''], true) && 'edit.php' === $pagenow) {
if (false === empty($search2_filter)) {
//What Should I do here? Something like:
//$query->set(?);
//?
}
}
return $query;
}
Share
Improve this question
asked Apr 11, 2024 at 19:29
user18102663user18102663
213 bronze badges
1 Answer
Reset to default 1There is only one parameter that will filter your results to posts that contain a value in the content, s
aka search, but doing so would break the search box. Unless you write code that on save updates a flag to indicate if the post contains that in its post content you can't have both
本文标签: queryHow to use parsequery() to add an additional filter based on content to page search
版权声明:本文标题:query - How to use parse_query() to add an additional filter based on content to page search? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736310739a1934488.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论