Forums › Forums › Search & Filter Pro › Setting a filter value on shortcode
Tagged: pre-filter, shortcode
- This topic has 6 replies, 2 voices, and was last updated 7 years, 9 months ago by Trevor.
-
Anonymous(Private) March 29, 2017 at 8:51 am #100103
Hi
I am running a custom theme, and have several custom post types that can be tagged with a custom taxonomy called
destination
.On the single template, below the post content, I want to show all other posts tagged with that same destination.
On the template, I have both filter and results shortcodes, and both are working as expected.
The results are showing, but as no filter is set on page load, it show all the posts.What I would like to know is if its possible to pre-set a filter on the shortcode to reflect the taxonomy that the post is tagged with, so that on page load the correct destination posts ar filtered
eg:
On a post tagged with ‘africa’, can I do something like:
<?php
$destination = ‘africa’; // get_term
echo do_shortcode(“[searchandfilter slug=’cards-filter’ _sft_destination=$destination]”);
?>Any help with this would be greatly appreciated.
ThanksTrevor(Private) March 31, 2017 at 2:16 pm #100608Ok. Great to talk with you Dominic. The only way you can do what you want, I think, is to use PHP to detect the destination category term, and then feed that into the S&F query using our Edit Query Arguments filter.
Let me know if you need any other help, or whether I can close the thread?
-
AuthorPosts