A valid Search with a long string returns empty query string
-
For long search string (700 Characters), no search string is received by parse_query(), i.e. on logging I got:
$_GET[‘s’] = ”
q[‘s] = ”
is_home = true
is_search = falseAnd for code :
add_filter( 'posts_search', 'extend_search', 500, 2 ); function extend_search($search, &$wp_query) { error_log(json_encode($wp_query)); $terms = $wp_query->query_vars[ 's' ]; error_log(json_encode($terms)); . . . return $search }
wp_query :
{“query”:[],”query_vars”:{“error”:””,”m”:””,”p”:0,”post_parent”:””,”subpost”:””,”subpost_id”:””,”attachment”:””,”attachment_id”:0,”name”:””,”static”:””,”pagename”:””,”page_id”:0,”second”:””,”minute”:””,”hour”:””,”day”:0,”monthnum”:0,”year”:0,”w”:0,”category_name”:””,”tag”:””,”cat”:11,”tag_id”:””,”author”:””,”author_name”:””,”feed”:””,”tb”:””,”paged”:0,”comments_popup”:””,”meta_key”:””,”meta_value”:””,”preview”:””,”s”:””,”sentence”:””,”title”:””,”fields”:””,”menu_order”:””,”category__in”:[],”category__not_in”:[],”category__and”:[],”post__in”:[],”post__not_in”:[],”post_name__in”:[],”tag__in”:[],”tag__not_in”:[],”tag__and”:[],”tag_slug__in”:[],”tag_slug__and”:[],”post_parent__in”:[],”post_parent__not_in”:[],”author__in”:[],”author__not_in”:[],”ignore_sticky_posts”:false,”suppress_filters”:false,”cache_results”:true,”update_post_term_cache”:true,”update_post_meta_cache”:true,”post_type”:””,”posts_per_page”:2,”nopaging”:false,”comments_per_page”:”50″,”no_found_rows”:false},”tax_query”:{“queries”:[],”relation”:”AND”,”queried_terms”:[],”primary_table”:null,”primary_id_column”:null},”meta_query”:{“queries”:[],”relation”:null,”meta_table”:null,”meta_id_column”:null,”primary_table”:null,”primary_id_column”:null},”date_query”:false,”post_count”:0,”current_post”:-1,”in_the_loop”:false,”comment_count”:0,”current_comment”:-1,”found_posts”:0,”max_num_pages”:0,”max_num_comment_pages”:0,”is_single”:false,”is_preview”:false,”is_page”:false,”is_archive”:false,”is_date”:false,”is_year”:false,”is_month”:false,”is_day”:false,”is_time”:false,”is_author”:false,”is_category”:false,”is_tag”:false,”is_tax”:false,”is_search”:false,”is_feed”:false,”is_comment_feed”:false,”is_trackback”:false,”is_home”:true,”is_404″:false,”is_embed”:false,”is_comments_popup”:false,”is_paged”:false,”is_admin”:false,”is_attachment”:false,”is_singular”:false,”is_robots”:false,”is_posts_page”:false,”is_post_type_archive”:false,”thumbnails_cached”:false,”updated_term_meta_cache”:false,”updated_comment_meta_cache”:false}
search query :
( ((wp_posts.post_title) LIKE ‘%%’) OR ((wp_posts.post_content) LIKE ‘%%’) )
So the query variable is empty and I am being redirected to homepage.
I have investigated all the core WordPress methods and documentations. Please help if anyone can throw some light on how to approach this behavior
- The topic ‘A valid Search with a long string returns empty query string’ is closed to new replies.