Forums › Forums › Search & Filter Pro › Different templates for different filter search
Tagged: category filter, results template
- This topic has 8 replies, 2 voices, and was last updated 9 years ago by Ross.
-
Anonymous(Private) December 9, 2015 at 6:06 pm #31834
I was wondering if it is possible with Search & Filter Pro to use a different template depending on the filter you are searching.
For example, let’s say the CPT for the search & filter was credit-cards and the filter was categories using a radio select of Balance Transfer, Rewards, Low APR.
Depending on which category you select, the results would be displayed differently. Balance transfer would show columns that Rewards and Low APR wouldn’t and so on.
The only way I was thinking something like this would be possible would be to create a new search form for each category. Are there any other ways this could be done?
Ross Moderator(Private) December 9, 2015 at 6:52 pm #31845Hi Eric
What you are after is not stricly possible but you can more or less achieve something similar.
Why not, in your template have a check to see which options have been selected / searched for and conditionally load different content?
You can check what a user has selected here:
http://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/And you can then load in different template “parts” using this:
https://codex.wordpress.org/Function_Reference/get_template_partThanks
Anonymous(Private) December 10, 2015 at 10:58 pm #31935So I’ve been trying to pull the field name from the Active Query Object, but I’m not able to pull any of custom fields, just categories.
I’m able to get _sft_credit_card_category, but not the post_meta fields of _sfm_issuer and _sfm_credit_quality.
<?php //grab the active query from our search form global $searchandfilter; $sf_current_query = $searchandfilter->get(615)->current_query(); var_dump($sf_current_query->get_array()); echo $sf_current_query->get_field_string("_sft_credit_card_category"); echo $sf_current_query->get_field_string("_sfm_issuer"); echo $sf_current_query->get_field_string("_sfm_credit_quality"); ?>
Ross Moderator(Private) December 10, 2015 at 11:27 pm #31936What are the results from that var_dump?
Do you see any of the other data in there?
Thanks
Anonymous(Private) December 11, 2015 at 1:08 am #31943array(5) { ["_sft_credit_card_category"]=> array(5) { ["name"]=> string(22) "Credit Card Categories" ["singular_name"]=> string(20) "Credit Card Category" ["all_items_label"]=> string(26) "All Credit Card Categories" ["type"]=> string(8) "taxonomy" ["active_terms"]=> array(1) { [0]=> array(3) { ["id"]=> int(20) ["name"]=> string(16) "Balance Transfer" ["value"]=> string(16) "balance-transfer" } } } ["_sfm_issuer"]=> array(5) { ["name"]=> string(0) "" ["singular_name"]=> string(0) "" ["all_items_label"]=> string(0) "" ["type"]=> string(9) "post_meta" ["active_terms"]=> array(1) { [0]=> array(2) { ["name"]=> string(15) "Bank of America" ["value"]=> string(15) "Bank of America" } } } ["_sfm_credit_quality"]=> array(5) { ["name"]=> string(0) "" ["singular_name"]=> string(0) "" ["all_items_label"]=> string(0) "" ["type"]=> string(9) "post_meta" ["active_terms"]=> array(0) { } } ["_sf_post_date"]=> array(2) { [0]=> string(0) "" [1]=> string(0) "" } ["_sf_sort_order"]=> array(0) { } }
Ross Moderator(Private) December 14, 2015 at 9:17 am #32138Hey Eric
get_post_meta()
is a WP function:
https://developer.wordpress.org/reference/functions/get_post_meta/I’m not sure its what you would need.
Could you by any chance send me a link to a search page, with a
var_dump
in the results area so I can see the error in action?Thanks
-
AuthorPosts