admin管理员组文章数量:1122826
I am using wordpress. What I am doing is, that when the user enters anything then it will search from the post and will show the result.
I have added static content $_REQUEST['keyword']="team";
just for an example, Every time I get it No search found.
Any idea what is the issue?
function universalSearch( $atts ) {
global $post;
$_REQUEST['keyword'] = "leanding"; // it's just an example
if ( ! empty( $_REQUEST['keyword'] ) ) {
$args = array(
'post_type' => 'post',
's' => $_REQUEST['keyword'],
'posts_per_page' => 5,
'post_status' => 'publish',
);
}
$result = new WP_Query( $args );
if ( $result->have_posts() ) {
while ( $result->have_posts() ) {
$result->the_post();
$tid = $result->ID;
echo '<p><a href="' . get_permalink( $post->ID ) . '">' . get_the_title( $post->ID ) . '</a></p>';
}
} else {
echo '<p><a href="javascript:void(0)">No search found.</a></p>';
}
wp_die();
}
I have check the wp query I am getting like this
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND (((wp_posts.post_title LIKE '{a30a32c58212e0e69da1fe713200b690a215277638267d3fc914587e000d21db}leanding{a30a32c58212e0e69da1fe713200b690a215277638267d3fc914587e000d21db}') OR (wp_posts.post_excerpt LIKE '{a30a32c58212e0e69da1fe713200b690a215277638267d3fc914587e000d21db}leanding{a30a32c58212e0e69da1fe713200b690a215277638267d3fc914587e000d21db}') OR (wp_posts.post_content LIKE '{a30a32c58212e0e69da1fe713200b690a215277638267d3fc914587e000d21db}leanding{a30a32c58212e0e69da1fe713200b690a215277638267d3fc914587e000d21db}'))) AND wp_posts.post_type = 'post' AND ((wp_posts.post_status = 'publish')) ORDER BY wp_posts.post_title LIKE
本文标签: pluginsWordpress search every time shows no search found even data exists
版权声明:本文标题:plugins - Wordpress search every time shows no search found even data exists 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736299304a1930421.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论