我想修改wp\\u ajax\\u find\\u posts函数。它从find posts表单接收搜索字符串,并通过ajax提供搜索结果。部分函数如下所示:
function wp_ajax_find_posts() {
global $wpdb;
check_ajax_referer( \'find-posts\' );
// ........
$search .= " OR ($wpdb->posts.post_title LIKE \'%{$term}%\') OR ($wpdb->posts.post_content LIKE \'%{$term}%\')";
$posts = $wpdb->get_results( "SELECT ID, post_title, post_status, post_date FROM $wpdb->posts WHERE post_type = \'$what\' AND post_status IN (\'draft\', \'publish\') AND ($search) ORDER BY post_date_gmt DESC LIMIT 50" );
$html = //......
$x = new WP_Ajax_Response();
$x->add( array(
\'what\' => $what,
\'data\' => $html
));
$x->send();
}
add_action( \'wp_ajax_find_posts\', \'wp_ajax_find_posts,1)
我想修改$post行,将post\\u author添加到查询中,以便将结果限制在当前loggin用户范围内。我想学习如何连接这个wp\\u ajax\\u find\\u post函数,让它接受我修改过的$post。我是否必须执行remove\\u action和add\\u action才能完全重写上述功能?