-
AuthorSearch Results
-
November 15, 2017 at 11:20 am #142055
In reply to: Manually get results
TrevorParticipantI am not entirely certain what you are doing with this, but WordPress needs to post the query to a page, which you could then use this to grab the query array:
$sf_current_query = $searchandfilter->get(7050)->current_query()->get_array();
Where you change the ID to the form ID of your form.
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'; }
September 15, 2017 at 8:41 am #131197In reply to: How do I get the form fieldvalues?
TrevorParticipantThe first thing then is to find what the array (data) looks like after you submit a search (with values in those two fields). Into whichever results template you are using, I need you to add this PHP code (before the loop runs), and it will print out the array of data to your screen, which you can then post back here within code ticks (the backwards quote mark that is on the key normally to the left of the main keyboard ‘1’ key, one before the code and one after it):
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(12345)->current_query()->get_array(); echo '<pre>',print_r($sf_current_query,true),'</pre>'; ?>
Where I have used
12345
, you need to replace that for the ID of your form.August 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 8:36 am #122348In reply to: Category Description
TrevorParticipantCan you use this code to print out the query:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(119)->current_query()->get_array(); echo '<pre>',print_r($sf_current_query),'</pre>'; ?>
July 24, 2017 at 8:17 am #122346In reply to: Ignoring filter for one result shortcode
TrevorParticipantThe first thing to do is to be able to print to your page the current query (which is an array), and do a few searches to see what the data looks like, when the category is set, and when it is set to ALL. You would do this using the PHP print_r function, so a quick search for snippets on this forum later …
See if this prints your query out:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(2051)->current_query()->get_array(); echo '<pre>',print_r($sf_current_query),'</pre>'; ?>
July 23, 2017 at 11:34 pm #122324In reply to: Category Description
AnonymousInactiveOkay I’ve worked out how to obtain the ID and get the description but the ID has an extra 1 at the end of the string which I’ve had to strip off.
Can you see why it would have the extra one and how to avoid it?
Thanks
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(119)->current_query()->get_array(); $currentCat = $sf_current_query['_sft_project_category']['active_terms'][0]['id']; $currentCatID = rtrim($currentCat,'1'); echo category_description( $currentCatID ); ?>
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
May 12, 2017 at 4:08 pm #108514In reply to: How to show the currently selected title only
TrevorParticipantYou tried this?
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(504)->current_query()->get_array(); echo '<pre>',print_r($sf_current_query),'</pre>'; ?>
-
AuthorSearch Results