Forums › Forums › Search & Filter Pro › Customize search results
Tagged: customize, results, search, showcountfilterterms
- This topic has 9 replies, 2 voices, and was last updated 7 years, 7 months ago by Trevor.
-
Anonymous(Private) March 3, 2017 at 8:21 am #94243
Hello.
I created a custom page where i want to display search results.
The page is: https://www.memoriecondivise.it/risultati-ricerca/
You can see search results by the search form on our home page https://www.memoriecondivise.itHow can we customize search results? We also want that the search terms appear on the page’s header like a real wp search. And we want that if there are no search results, the page will display a not found search error.
Example
Trevor(Private) March 3, 2017 at 1:07 pm #94306The appearance of the search results, generated from our plugin’s form (which is using the ‘As an Archive’ Display Results method), are determined the template of your theme for that page. At this time, the search parameters cannot be detailed except by custom coding with PHP, by extracting data from the sf_query array. You can see an example in this thread. This is a feature we hope to introduce in the next major version (V3), which is some months away yet (but already in progress).
Similarly, the ‘No results found message’ comes from your theme templates.
Anonymous(Private) March 7, 2017 at 8:12 am #95084I’ve no problem to insert php code in the file, i follow your suggestion with the example thread but not working.
Can you send me the right PHP code to insert in search.php file and finally display something like this:
Search for {Search_Key}. Find {Number_Of_Results} results.
Thanks
Trevor(Private) March 7, 2017 at 11:30 am #95136Hi Marco
The code required is not easy to figure. You would need to dump the sf_query array (using print_r) inside
<pre></pre>
tags and then figure which element(s) you want. This will be variable because the user may search different fields. Then the number of results is harder to find. I was unable to work that out last time I tried. I did spend weeks on that last code example I showed, and that is outside the remit of our support, as this feature is not an advertised feature.For now I would advise you wait for the next version.
Trevor(Private) March 9, 2017 at 7:13 pm #95823Hi
Thinking about this some more. In the WordPress Codex:
https://codex.wordpress.org/Plugin_API/Filter_Reference/found_posts
So that should give you what you the count that you want, yes? In a standard WordPress query, the query array is $wp_query, but your theme may have a customised version, but it should have the
found_posts
variable still.If you take a look at this part of our documentation, Ross has added some examples that you could use to get the search terms in the fields/taxonomies.
I think you should be able to use these examples to make your own code? The last example especially (for you).
Anonymous(Private) April 4, 2017 at 9:31 am #101327Hi kind Trevor
You said me on 7 March: For now I would advise you wait for the next version.
Now I upload last version (2.3.3).
Do you know if there is some news about this topic (to show something like this in Result Page: Search for {Search_Key}. Find {Number_Of_Results} results)?
Thanx for your help. -
AuthorPosts