Result list say "Search results for — " "
-
This is a great plug-in! I am using it on https://www.520families.com
When a person searches on a few fields (type, location, etc.) the result list is accurate. However, at the top of the list is the text “Search results for – ” “
Is there a way to display what has been searched within those quotes?https://www.ads-software.com/plugins/ultimate-wp-query-search-filter/
-
Depend on your theme how it define the search term. Normally, Some use get_search_query(), some use the_search_query(), there are also other way to display the search term.
Check on your theme, then you can extract the search terms from the URL by$_GET[]
method. Of course, some PHP skill needed.I can modify but, sadly, not yet write PHP. I am using the Frontier theme and it seems to use the get_search_query in the Main Index Template file (index.php).
I can see that the terms I am using with WP Query Search Filter (age, type, location) on my website are (obviously) not referenced in the code:
<?php if ( is_category() || is_tag() || is_date() || is_search() ) : ?>
<div class=”archive-info”>
<h3 class=”archive-title”>
<?php
if ( is_search() )
printf( __(‘Search Results for – "<span>%s</span>"’, ‘frontier’), get_search_query() );
elseif ( is_day() )
printf( __(‘Date – <span>%s</span>’, ‘frontier’), get_the_date() );
elseif ( is_month() )
printf( __(‘Month – <span>%s</span>’, ‘frontier’), get_the_date( ‘F Y’ ) );
elseif ( is_year() )
printf( __(‘Year – <span>%s</span>’, ‘frontier’), get_the_date( ‘Y’ ) );
elseif ( is_category() || is_tag() )
echo ‘<span>’ . single_cat_title( ”, false ) . ‘</span>’;
?>
</h3><?php if ( category_description() != ” ) : ?>
<div class=”archive-description”><?php echo category_description(); ?></div>
<?php endif; ?>
</div>
<?php endif; ?>To extract the search terms from this URL https://520families.com/?unonce=c1440da974&uformid=98&s=uwpsfsearchtrg&taxo%5B0%5D%5Bname%5D=age&taxo%5B0%5D%5Bopt%5D=1&taxo%5B1%5D%5Bname%5D=type&taxo%5B1%5D%5Bopt%5D=1&taxo%5B2%5D%5Bname%5D=location&taxo%5B2%5D%5Bopt%5D=1
am I looking at extracting age, type, location? And putting them where?
You can use the
get_search_filter()
filter to customize it without touching the template.
eg. of use:add_filter( 'get_search_query', 'uwpqsf_var', 20, 1 ); function uwpqsf_var($s){ if(is_search() && isset($_GET['s']) && $_GET['s'] == 'uwpsfsearchtrg' && isset($_GET['uformid']) ){ if(isset($_GET['taxo'])){ foreach($_GET['taxo'] as $v){ if(isset($v['term'])){ if($v['term'] == 'uwpqsftaxoall'){ }else{ $termname = get_term_by('slug',$v['term'],$v['name']); $var[] = $termname->name; } } } $return = ''; if(!empty($var)){ $return = implode(' | ', $var); } return $return; } } }
This example is for get the searched taxonomy term. If you want to get the meta fields, you can use
$_GET['cmf']
.You need to organize the search term well when combining the taxonomy and meta field search term.
The php code above works pretty good BUT searching terms on theme displays ‘Search results for ” “‘ on the contrary.
How can I have both displaying the search terms within quotes?
It is depends on your theme how it display the searched result terms.
Thank you for your reply.
My theme displays like this below
if(is_search()) {
$title = __(‘Search results for ‘ , IT_TEXTDOMAIN) . ‘”‘ . get_search_query() . ‘”‘;
}Please advise me.
Then it should work.
What do you want to do exactly? I am confused, can you provide examples?I recently just switched from the Advanced WQSF to Ultimate WPQSF, so far the plugin is great and this thread helped me to display Search results for ” (Category selected)” How would I display Search Results for “Keyword input to String Search”. For example if someone used to the string search to search for Irrigation Tires. I want the top of the search page to read Search Results for “Irrigation Tires” . As of now it reads Search results for “”, unless they pick a category or brand from my taxonomy drop downs, and those selected taxonomies do show up, thanks to your code above. Any advice would be great.
@digital_jedi,
Adding the string search to the snippet above:add_filter( 'get_search_query', 'uwpqsf_var', 20, 1 ); function uwpqsf_var($s){ if(is_search() && isset($_GET['s']) && $_GET['s'] == 'uwpsfsearchtrg' && isset($_GET['uformid']) ){ if(isset($_GET['taxo'])){ foreach($_GET['taxo'] as $v){ if(isset($v['term'])){ if($v['term'] == 'uwpqsftaxoall'){ }else{ $termname = get_term_by('slug',$v['term'],$v['name']); $var[] = $termname->name; } } } if(!empty($_GET['skeyword'])){ $var[] = $_GET['skeyword']; } $return = ''; if(!empty($var)){ $return = implode(' | ', $var); } return $return; } }else{ return $s; } }
Thank you! That worked perfectly. You are awesome!
This works if you use the search field.
I the case that you don’t need a search filed, instead you create a filter with checkboxes this function does not work.Any suggestion appreciated.
Thanks in advance.
It’s show works, but you need to tweak the scripts.
Since checkboxe is an array, so in the functions you will need to extract the array.
eg:foreach($_GET['taxo'] as $v){ if(isset($v['term'])){ if($v['term'] == 'uwpqsftaxoall'){ }else{ //here we extract the array again foreach($v[term] as $singleterm){ $termname = get_term_by('slug',$singleterm,$v['name']); $var[] = $termname->name; } } } }
note that the above codes only work for checkbox field, if you have multiple fields in the form, it will produce error.
The point at here is the php. You need to know how to manipulate the data.Great plugin! ??
Kindly help me on my site:I have 3 dropdown search and I used the ajax filter.
I’m using the AND statement.
The problem is when i search the result display like this.
Search Results :
———
Items
——–
Can you add the Search Results with a title you have search?like this one
Search Results : chair | dinning
———
Items
——–
when nothing found:Search Results : chair | dinning
———
Nothing Found
——–I also suffer from problems like you, to thank the experts who helped, I’m trying to overcome…
If you using the Ajax template, then you should customize the results with
uwpqsf_result_tempt
.For eg, inside the filter function,
add_filter('uwpqsf_result_tempt', 'customize_output', '', 4); function customize_output($results , $arg, $id, $getdata ){ // The Query $apiclass = new uwpqsfprocess(); $query = new WP_Query( $arg ); ob_start(); $result = ''; //here you can get the search query via $getdata. //just like the codes above //eg. if(isset($getdata['taxo'])){ foreach($getdata['taxo'] as $v){ if(isset($v['term'])){ if($v['term'] == 'uwpqsftaxoall'){ }else{ $termname = get_term_by('slug',$v['term'],$v['name']); $var[] = $termname->name; } } } if(!empty($getdata['skeyword'])){ $var[] = $getdata['skeyword']; } $return = ''; if(!empty($var)){ $return = implode(' | ', $var); } echo $return; // The Loop if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post();global $post; echo '<li>'.get_permalink().'</li>'; } echo $apiclass->ajax_pagination($arg['paged'],$query->max_num_pages, 4, $id, $getdata); } else { echo 'no post found'; } /* Restore original Post Data */ wp_reset_postdata(); $results = ob_get_clean(); return $results; }
- The topic ‘Result list say "Search results for — " "’ is closed to new replies.