Forums › Forums › Search & Filter Pro › First session without results, how to do it?
- This topic has 5 replies, 2 voices, and was last updated 3 years, 11 months ago by Trevor.
-
Anonymous(Private) January 26, 2021 at 10:14 pm #274146
Hello,
I need to activate a “Ajax” search form in the home page but without results when a user open it the first time.
I’m using “Beaver Builder Posts Module” to see the results but I don’t have problem to change it with the “shortcode” modality, but before I’d like to know how start the session without results on the page.
Thanks.Trevor(Private) January 27, 2021 at 6:06 am #274170Using the Shortcode method, you would need to edit the results.php file, as detailed in this post:
You would need to follow our guide when doing that:
https://searchandfilter.com/documentation/search-results/using-a-shortcode/#customising-the-results
Anonymous(Private) January 27, 2021 at 7:59 am #274198Hello Trevor,
can you please confirm the following?1) I’ve created a custom results page with the ID (14) of the search form…
wp-content\themes\my-child-theme-name\search-filter\14.php
2) … I’ve put all the current php code, except:
if ( ! defined( 'ABSPATH' ) ) { exit; }
3) … in the section commented “// the current results.php code here”
global $searchandfilter; $sf_current_query = $searchandfilter->get(14)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { if ( $query->have_posts() ) { ?> ...
Is the above procedure correct?
If I need to translate the website (using WPML), do I need to create a new search form and a new custom results page (so with another ID)?Thanks.
Anonymous(Private) January 27, 2021 at 9:16 am #274219Another question… is it possible to have in the dropdown menu, the voice “All” that selecting it load all the results?
Is not important (I can change the name from “All” to “Select”), but this option would give the search a full function.
Thanks.Anonymous(Private) January 27, 2021 at 10:27 pm #274358Another “little” request… I’ve inserted this code in the page to show the taxonomies but I don’t know how to customise it (e.g. change the separator “,” and remove the “and” for the last value when the list is multiple and the dot at the end “.”, remove/change the taxonomy title before of the values):
<p><?php the_taxonomies(); ?></p>
How can I do it?
Trevor(Private) January 28, 2021 at 9:36 pm #274475The code looks OK. When you translate a form it gets a different ID, so you can do the same but with a different filename instead of 14.php for example.
I have not seen an easy way to change the All label, you might need to use JavaScript to do this.
As for that function, I can only refer you to the WordPress Codex for options:
https://developer.wordpress.org/reference/functions/the_taxonomies/
-
AuthorPosts