-
Search Results
-
Hi,
I have managed to return the selected taxonomy string when I filter the posts. I would like to know how can I return the slug also?
My code:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(909)->current_query(); $sf_args = array( "str" => '%2$s', "delim" => array(", ", " - "), "field_delim" => ', ', "show_all_if_empty" => false ); $current_selected_taxonomy = $sf_current_query->get_field_string("_sft_thema", $sf_args); ?> <?= $current_selected_taxonomy ?>Thanks!
Hello,
At the moment i am building a website where people can filter posts. Once filtered it is the intention that it should be possible for people to leave their emailadress. Once they do that i save the “$sf_current_query->get_search_term()” and “$sf_current_query->get_array()” to the database to make it possible to repeat the query.
Would it be possible to use the saved data to query the results later on? if so with which function? I already tried “set_field_values_array()” but i cannot get it to work.
The results do not need to be filtered, i just want to check if there are any results afterwords with WP_Query.
Hope that you can help me with the above, thanks in advance!
I tried following this: https://searchandfilter.com/documentation/accessing-search-data/
Here is the code:
global $searchandfilter; $sf_current_query = $searchandfilter->get(56)->current_query(); //var_dump($sf_current_query->get_array()); $searchArgs = array( "str" => '%2$s', "delim" => array(", ", " - "), "field_delim" => ', ', "show_all_if_empty" => false ); echo $sf_current_query->get_fields_html( array( "_sfm_caster-wheel-size", "_sfm_caster-wheel-material", "_sfm_caster-fastening-type", "_sfm_caster-load-capacity" ), $searchArgs );When I do a var_dump, it shows the info that is expected (hidden for now) — so the id and everything seems to be correct.
However, when I try to display any of the field values, nothing shows up.No errors in console message or anything either.
I am trying to get it to say “Search Results 10″, Air Flat/Free, Top Plate”
Hi,
we use the Search & Filter Pro on our website to filter a custom posttype (sneakers) with 5 taxonomies (brand, model, color, target audience, age). We created a custom archive for each of these 5 taxonomies.
We only created one “search form”.In the archive for a specific model for example we call the Search & Filter Pro filters using :
$sf_current_query = $searchandfilter->get(7183946)->current_query();
We get a nice list of sneakers that match the current model. But what it also shows if we call the filter using a shortcode (<?php echo do_shortcode( ‘[searchandfilter id=”7183946″]’ ); ?>) – so we can filter on color, target audience and age, the brand and model also are there. From a user experience we find this obsolete so we have hidden it using css override in the archive page :
<style>
select[name=”_sft_brand[]”] {
display : none;
}
select[name=”_sft_model[]”] {
display : none;
}
</style>Unfortunately this results in our page having a lot of (irrelevant) DOM elements which we would like to exclude. This is because all brands and models are still available in the filter (while hidden using CSS). Please note we have a lot of brands and models and we want to keep the page as clean as possible.
How can we achieve this? Is there a way we can eliminate the DOM elements of brand and model on this particular taxonomy archive? For example on the model taxonomy we want to filter out the brand and model and on the brand page we want to disable the brand.
Mark
PS. Please check https://www.solezilla.nl/model/nike-air-max-90/ for an example
I am trying to change the default landing state of a page from ‘all’ to a sepcific category or value. (i.e education) I am using a shortcode and am customising the php file. I am using a custom field of ‘projects’ and filtering these using a checkbox filter by ‘project-type’ (eg. education, commercial etc.)
Reading through the forum I think I need to use a combination of these three snippets but cannot put them together. Can anyone help out?
1.
function filter_function_name($input_object, $sfid)
{
if($input_object[‘name’]==’_sft_project-type’)||($input_object[‘type’]!=’select’))
{
//udpate this field before rendering
}return $input_object;
}
add_filter(‘sf_input_object_pre’, ‘filter_function_name’, 10, 2);2.
$input_object[‘defaults’] = array(“education”);
3.
//Get an array of objects containing data for the current search/filter
//replace1526with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(43)->current_query();
echo $sf_current_query->is_filtered();