Search does not work with the current theme but it works well with another. Why? !!
Like using my template and modify many things in it and do not want to change it, but I was surprised that the search in the questions does not work but when change theme work well.
What is the relation between the theme and search in questions?
And how to solve this problem?
Thanks for your Support
hamed commented
no
i have other theme and change it to twenty thirteen which work well with it
hamed commented
If i want to use other Theme for anspress only for solve the problem how can I do that?
Hello, i had the same problem. In my case the problem was in the file functions.php this were my problem, i hope this will help you:
function my_smart_search( $search, &$wp_query ) { global $wpdb; if ( empty( $search )) return $search; $terms = $wp_query->query_vars[ 's' ]; $exploded = explode( ' ', $terms ); if( $exploded === FALSE || count( $exploded ) == 0 ) $exploded = array( 0 => $terms ); $search = ""; foreach( $exploded as $tag ) { $search .= " AND ( (wp_posts.post_title LIKE '%$tag%') OR (wp_posts.post_content LIKE '%$tag%') OR EXISTS ( SELECT * FROM wp_comments WHERE comment_post_ID = wp_posts.ID AND comment_content LIKE '%$tag%' ) OR EXISTS ( SELECT * FROM wp_terms INNER JOIN wp_term_taxonomy ON wp_term_taxonomy.term_id = wp_terms.term_id INNER JOIN wp_term_relationships ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id WHERE taxonomy = 'post_tag' AND object_id = wp_posts.ID AND wp_terms.name LIKE '%$tag%' ) )"; } return $search; } add_filter( 'posts_search', 'my_smart_search', 500, 2 ); function buscador_mostrar_solo_posts($query){ if ($query->is_search) { $query->set(‘post_type’, ‘post’); } return $query; } add_filter(‘pre_get_posts’, ‘buscador_mostrar_solo_posts’);
Rahul Aryan edited answer
What is your current theme? our theme?