Forums › Forums › Search & Filter Pro › Display selected category in WordPress template
- This topic has 4 replies, 2 voices, and was last updated 4 years, 9 months ago by Trevor.
-
Anonymous(Private) January 23, 2020 at 1:26 pm #231919
Hey there
Title summerizes what I’m trying to do – I’d like to display the selected category on my WordPress template, currently I’m displaying the search result but not the category, so if a user only selects a category I end up with a blank title, here’s an example;
Title at the top reads “Search results for: ”
https://love-glamping.co.uk/?sfid=51345&_sft_category=cornwall
Simple piece of code to do this is this;
<?php printf( /* translators: %s: query term */ esc_html__( 'Search Results for: %s', 'understrap' ), '<span>' . get_search_query() . '</span>' ); ?>
Is there something I can add to this to get the category data? %c for example?
Sorry, I couldn’t find the answer in the documentation
Trevor(Private) January 23, 2020 at 1:55 pm #231924The currently applied filters are accessible to PHP. You would need the help of a skilled third party PHP coder, I think.
This thread might help you:
https://support.searchandfilter.com/forums/topic/accessing-field-slug-on-search-results/
… and this search will give similar threads I think:
https://support.searchandfilter.com/forums/search/sf_current_query+get_array
Note, if you are using Ajax refreshing of the results, any PHP needs to be inside the Ajax Container, or it will not update.
Anonymous(Private) January 24, 2020 at 4:17 pm #232050This got me heading in the right direction but I needed a little help so had to go to Stack Over flow but the solution is really simple
So future people needing this here how I did it – https://stackoverflow.com/questions/59882323/displaying-correct-value-from-array-values-in-php?noredirect=1#comment105893774_59882323
Thanks again for the brilliant support
-
AuthorPosts