-
AuthorSearch Results
-
March 2, 2018 at 5:10 pm #163335
In reply to: How to make filter label appears in the search field
AnonymousInactiveThank you ! Yes you’re right it displays the entire query ! How to keep only all the [value] results ?
Array
(
[_sfm_prenom-du-commissaire] => Array
(
[name] =>
[singular_name] =>
[all_items_label] =>
[type] => post_meta
[active_terms] => Array
(
[0] => Array
(
[name] => Anaëlle T.
[value] => Anaëlle T.
))
)
[_sfm_jour-de-la-visite] => Array
(
[name] =>
[singular_name] =>
[all_items_label] =>
[type] => post_meta
[active_terms] => Array
(
[0] => Array
(
[name] => Jeudi
[value] => Jeudi
)[1] => Array
(
[name] => Lundi
[value] => Lundi
))
)
)
January 24, 2018 at 8:57 pm #154736In reply to: Breadcrumbs Revisited – Hoping for Confirmation
AnonymousInactiveUnfortunately that’s a no-go. The complete code I put in (using your good chunk there) looked like:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(15)->current_query()->get_array(); echo '<strong>Filtered by:</strong>'; if ( is_empty($sf_current_query ) ) { echo "all"; } else { foreach($sf_current_query as $key) { echo ' • ' . $key['active_terms'][0]['name'] . ' '; } }?>
Am I missing something above if? Feels like that’s maybe where I’m off?
(The page does not display anything – no sidebar, no search form, so as-is above it pretty broken – did I close off the function properly?)December 14, 2017 at 9:06 pm #147706In reply to: Taxonomy Breadcrumbs
AnonymousInactiveFor clarity, this is what I used:
global $searchandfilter; $sf_current_query = $searchandfilter->get(339)->current_query()->get_array(); foreach($sf_current_query as $key) { echo '<div>' . $key['active_terms'][0]['name'] . '</div>'; }
November 10, 2017 at 4:25 am #141086In reply to: Some Ui questions
AnonymousInactiveok, great help over skype Trevor – exactly what i was after and pretty much all sorted – thanks!
for anyone interested
1. use pre and print r instead of var dump to get the bits you need:
$sf_current_query = $searchandfilter->get(7050)->current_query(); echo '<pre>'; print_r($sf_current_query->get_array()); echo '</pre>';
2. I ended up with this in my page template to target the ACF meta name chosen in the S&F query – i also ended up trying to cope with the All values parts being sent if no specific options are selected (i hide all items selection in front end):
global $searchandfilter; $sf_current_query = $searchandfilter->get(7050)->current_query()->get_array(); if ($sf_current_query['_sfm_comfort']['active_terms'][0]['name'] == ""){ echo 'no preference for comfort'; } else { echo '$sf_current_query['_sfm_comfort']['active_terms'][0]['name'] . ' comfort'; }
November 7, 2017 at 7:53 am #140420In reply to: Some Ui questions
AnonymousInactiveHi Trevor, got a little further with styling so thanks for that. One thing with accessing the search data so I can display what’s been searched for – i’ve looked at
https://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/
but am not getting any output. I’m using ACF meta fields for all the search criteria so maybe I need to use something differently?
?_sfm_comfort=medium&_sfm_value_judgement=bestquality&_sfm_state=wa
is the query stringi’m using this in the custom page template:
echo $sf_current_query->get_fields_html(
array(“_sfm_comfort”)
);echo $sf_current_query->get_field_string(“_sfm_comfort”);
also doesn’t give any result.
the var dump gives:
array(3) { [“_sfm_comfort”]=> 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(6) “Medium” [“value”]=> string(6) “medium” } } } [“_sfm_value_judgement”]=> 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(12) “Best Quality” [“value”]=> string(11) “bestquality” } } } [“_sfm_state”]=> 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(2) “WA” [“value”]=> string(2) “wa” } } } }help appreciated – cheers
MikeAugust 8, 2017 at 9:32 am #124975
AnonymousInactiveHi Trevor,
Thanks for the reply, I found the solution:
global $searchandfilter; $sf_current_query = $searchandfilter->get(1274)->current_query()->get_array(); foreach($sf_current_query as $key) { echo '<span>' . $key['value'] . ' ' . $key['name'] . ' ' . $key['active_terms'][0]['name'] . ', </span>'; }
July 24, 2017 at 9:04 am #122357In reply to: Category Description
AnonymousInactiveI get the following (you can see a 1 at the end of the array):
Array ( [_sft_project_category] => Array ( [name] => Product Categories [singular_name] => Product Category [all_items_label] => All Categories [type] => taxonomy [active_terms] => Array ( [0] => Array ( [id] => 6 [name] => Fruit [value] => fruit [count] => 7 ) ) ) [_sft_project_tag] => Array ( [name] => Product Tags [singular_name] => Product Tag [all_items_label] => All Tags [type] => taxonomy [active_terms] => Array ( [0] => Array ( [id] => 8 [name] => 6+ Months [value] => 6-months [count] => 11 ) ) ) ) 1
May 14, 2017 at 1:44 pm #108703In reply to: How to show the currently selected title only
AnonymousInactiveGOT IT!!!
global $searchandfilter; $sf_current_query = $searchandfilter->get(504)->current_query()->get_array(); if (empty($sf_current_query)) { echo ('All Articles'); } else { echo $sf_current_query['_sft_category']['active_terms'][0]['name']; }
The above code worked like a charm, I also use the “Archive” setting as you suggested! Thanks so much for your help on this one!! Finally working properly!! 🙂
May 13, 2017 at 2:49 pm #108628In reply to: How to show the currently selected title only
AnonymousInactiveHi Trevor,
UPDATE! I’ve managed to half get it working!!!
It now works for all categories except the “All Categories” one, this seems to behave differently to the others and the code I have used doesn’t bring it in:
$sf_current_query = $searchandfilter->get(766)->current_query()->get_array(); echo $sf_current_query['_sft_category']['active_terms'][0]['name'];
I’ve left the printr statement in on the live site so you can get a picture of what is happening. I presume there may need to be an if statement added but I have yet to be able to pull in the “All categories” heading… I was however thinking of just hard coding a title in as it is only one title?? But i’m not sure how I would do it. I’m sure there is a “proper” fix to this though?
I hope you have a good weekend
March 10, 2017 at 2:36 pm #95975In reply to: Accessing the Search Data
AnonymousInactiveI found some workaround, to display currently selected value:
$tmp = $sf_current_query->get_array(); echo $tmp["_sfm_character"]["active_terms"][0]["name"];
But it may be a bug in
get_field_string
method from documentation, which is not working in my case:echo $sf_current_query->get_field_string("_sfm_character");
-
AuthorSearch Results