Forums › Forums › Search & Filter Pro › Search results
- This topic has 19 replies, 2 voices, and was last updated 6 years ago by Trevor.
-
Anonymous(Private) October 29, 2018 at 6:38 pm #192056
Hello. I use shortcode method to display search results. I have search filter, and I want to change title on page from Recent posts to Search for <value from search> when search is completed. I tried to do it as js, with sf:ajaxfinish, but it dont show anymore in console. How i can do it in results page? Instead of js, if it possible.
Trevor(Private) October 30, 2018 at 11:50 am #192106Line 42 of your custom results.php looks like this:
<div class="blog-post__title"><a href="<?php the_permalink();?>"><?php the_title();?></a></div>
It does not need the
<a href="<?php the_permalink();?>">
and closing</a>
as it is not a link, and you can replace the<?php the_title();?>
with code to show what you want.This documentation is a start:
https://searchandfilter.com/documentation/accessing-search-data/
But you can use more complex code that the snippets shown.
Trevor(Private) October 30, 2018 at 1:50 pm #192127The text that says Recent post is what that line I highlighted makes. In any event that lines needs to be this instead, I think (try it):
<div class="blog-post__title"><?php the_title();?></div>
So, you would now need to find out if the page is filtered, like this, where the last line replaces line 42:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(1024)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { $page_title = the_title(); } else { $page_title = "Search results for: " . $sf_current_query->get_search_term(); }?> <div class="blog-post__title"><?php echo $page_title;?></div>
Note that this only shows the text search term. If you want fields choices, taxonomy choices, it becomes more complicated, which is what that documentation page shows how to do..
Anonymous(Private) October 30, 2018 at 5:27 pm #192194This is similar to what I need, but not at all.
I have blog-page.php in my theme, and in line 24 i have:
<div class="page-blog page-blog-title">Recent posts</div>
I want chagne this, not in results.php loop.I tried to put your code in blog-page.php, but ajax do not working.
Trevor(Private) October 30, 2018 at 5:32 pm #192200When I looked at your site, you had two forms. One was using our shortcode method, and that is what is used on the page (not the template you mention). In your theme (or child theme) folder, you had a sub-folder called search-filter. In that was the results.php template.
-
AuthorPosts