Forums › Forums › Search & Filter Pro › How to set a title for every search
- This topic has 9 replies, 2 voices, and was last updated 7 years, 4 months ago by Trevor.
-
Anonymous(Private) June 28, 2017 at 8:22 pm #117477
Hello,
this is a great plugin but i can’t figure out one thing. Is is possible to change the title of the page in any given search.
I mean when the results are loading with Ajax aso change the titlte of the page for example is user is searching for a custom field named genre and the term is rock I need on ajax to change the title of the page to “search result for genre:Rock”, if the user searches for term Jazz, then the title of the page will be “search result for genre: Jazz”
I tried using
global $searchandfilter;
$sf_current_query = $searchandfilter->get(123)->current_query();
echo $sf_current_query->get_field_string(“_sft_genre”);but this only returns the initial genre, it doesn’t change if the user changes the filter “genre”
Trevor(Private) July 5, 2017 at 1:10 pm #118898Are you using a template PHP file for the results (maybe modified by you) OR a template PHP file that you have written?
With Ajax ON, the S&F form will have an Ajax Container defined (default is
#main
, but many themes have this differently, so you need to check) and the code for the title has to be placed within this Ajax Container. That means that the title must also be inside this container. Note that the form should NOT be inside this container.Anonymous(Private) July 5, 2017 at 1:22 pm #118900I have used my template. and the results are showing perfectly. The container is #ajaxcontainer and it is set in the roem attributes. The form is not in the container. So when I add a <?php the_title(); ?> outside the #ajaxcontainer i get nothing! when I adden it inside the #ajaxcontainer I get the title of the first post received from the search.
What I need is a page title “search result for genre: Jazz” and then all my products
Anonymous(Private) July 5, 2017 at 9:33 pm #118995ok. That worked when i added the title inside the ajax results container.
Is it possible to also change values in other parts of the page depending on the filter selection?
What I want to achieve is
I have a main filter and then some secondary filters… I wan to load different secondary filters depending the selection of the first filter. IS this possibleThanks in advance
Trevor(Private) July 6, 2017 at 10:59 am #119037I imagine it could be possible, but only with some serious custom coding. What you could do is write some javascript that watches for our Ajax to finish (see our FAQ page for code examples) and use that to then maybe trigger changes elsewhere on the page.
-
AuthorPosts