admin管理员组文章数量:1404464
I've just spent 2 days on trying to pass/change an argument in a plugin's function but had no luck so far. Would anyone, please, show me the correct way or solution how to do that?
I need to be able to change value 'cat' => '44'
with a shortcode to any other value written in that shortcode for instance [search cat="15"]
would make the 'cat' => '15'
in the function.
function search() {
if ( isset( $_REQUEST['swpquery'] ) && ! empty( $_REQUEST['swpquery'] ) ) {
$query = sanitize_text_field( $_REQUEST['swpquery'] );
if ( class_exists( 'SearchWP' ) ) {
// SearchWP powered search
$posts = $this->searchwp( $query );
$args = array(
'post_type' => 'any', // We're limiting to a pre-set array of post IDs.
'post_status' => 'any', // We're limiting to a pre-set array of post IDs.
'post__in' => $posts,
'orderby' => 'post__in',
'suppress_filters' => true,
);
} else {
// native WordPress search
$args = array(
's' => $query,
'post_status' => 'publish',
'cat' => '44',
'post_type' => get_post_types( array(
'public' => true,
'exclude_from_search' => false,
) ),
);
}
$args['posts_per_page'] = $this->get_posts_per_page();
$args = apply_filters( 'searchwp_live_search_query_args', $args );
$this->show_results( $args );
}
// Short circuit to keep the overhead of an admin-ajax.php call to a minimum.
die();}
Thanks so much for any help.
本文标签: Edit plugin function with a hook
版权声明:本文标题:Edit plugin function with a hook 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744805882a2626141.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论