-
AuthorSearch Results
-
March 11, 2020 at 11:35 am #236248
In reply to: Category description in search results
TrevorParticipantI added this code:
https://www.screencast.com/t/WYIjHhwBYb
This:
global $searchandfilter; $sf_current_query = $searchandfilter->get(332)->current_query(); $sf_current_query_array = $searchandfilter->get(332)->current_query()->get_array(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>No category selected.</div>'; } else { echo '<div>' . $sf_current_query_array["_sft_category"]["active_terms"][0]["value"] . '</div>'; echo '<div>' . $sf_current_query_array["_sft_category"]["active_terms"][0]["id"]. '</div>'; echo '<div>' . category_description($sf_current_query_array["_sft_category"]["active_terms"][0]["id"]). '</div>'; }
February 17, 2020 at 5:12 pm #234134In reply to: Search Term not showing on Custom Archive Page
TrevorParticipantSo, that would be:
echo $sf_current_query["_sfm_city"]["active_terms"][0]["value"];
I think.
February 17, 2020 at 5:01 pm #234128In reply to: Search Term not showing on Custom Archive Page
AnonymousInactiveIt really doesn’t give me anything different then what i see above.
It shows what I queried but I simply need to display the Name of the City…when i attempt to use the first query i showed above to show _sfm_city it doesn’t display anything. How do i get the name of the city to display:
[_sfm_city] => Array ( [name] => [singular_name] => [all_items_label] => [type] => post_meta [active_terms] => Array ( [0] => Array ( [name] => Caracas [value] => Caracas ) ) ) )
<?php //Get a single fields values using labels //replace <code>1526</code> with the ID of your search form global $searchandfilter; $sf_current_query = $searchandfilter->get(1902)->current_query(); echo $sf_current_query->get_field_string("_sft_city"); ?>
February 17, 2020 at 4:24 pm #234105In reply to: Search Term not showing on Custom Archive Page
AnonymousInactiveSo i was able to use your documentation to grab the following query output: However, when i attempt to call the field _sfm_city it does not display anything. This is a Meta Key, does that matter? My attempt to display it is listed below
Array ( [_sft_specialties] => Array ( [name] => specialties [singular_name] => Specialty [all_items_label] => All Items [type] => taxonomy [active_terms] => Array ( [0] => Array ( [id] => 355 [name] => Test Matter Type [value] => test-matter-type [count] => 1 ) ) ) [_sft_providers-category] => Array ( [name] => Categories [singular_name] => Categories [all_items_label] => Categories [type] => taxonomy [active_terms] => Array ( [0] => Array ( [id] => 68 [name] => Patent Search [value] => patent-search [count] => 1 ) ) ) [_sft_operatingcountries] => Array ( [name] => Operation Countries [singular_name] => Operating Countries [all_items_label] => All Operating Countries [type] => taxonomy [active_terms] => Array ( [0] => Array ( [id] => 145 [name] => Denmark [value] => denmark [count] => 1 ) ) ) [_sfm_city] => Array ( [name] => [singular_name] => [all_items_label] => [type] => post_meta [active_terms] => Array ( [0] => Array ( [name] => HARARE [value] => HARARE ) ) ) )
`<?php
//Get a single fields values using labels
//replace1526
with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(1902)->current_query();
echo $sf_current_query->get_field_string(“_sft_city”);?>
April 23, 2018 at 6:50 pm #173861In reply to: Select Box Like Ted
AnonymousInactiveThis is the output (the terms are there for post_types—pages and practices) but I can’t seem to display it with in the same manner as the categories.
<?php $args = array( "str" => '<ul class="filters-list"><li>%2$s<i class="fa fa-times"></i></li></ul>', "delim" => array('<i class="fa fa-times"></i></li> <li>', '–'), "field_delim" => ' , ', "show_all_if_empty" => false ); echo $sf_current_query->get_fields_html( array("_sft_category","post_types"), $args ); echo '<pre>'; print_r($sf_current_query); echo '</pre>'; ?>
output:
Search_Filter_Active_Query Object
(
[sfid] => 299
[is_set:Search_Filter_Active_Query:private] => 1
[query_array:Search_Filter_Active_Query:private] => Array
(
[_sft_category] => Array
(
[name] => Categories
[singular_name] => Category
[all_items_label] => All Categories
[type] => taxonomy
[active_terms] => Array
(
[0] => Array
(
[id] => 56
[name] => Community Development
[value] => community-development
[count] => 5
)[1] => Array
(
[id] => 57
[name] => Environment
[value] => environment
[count] => 1
))
)
[post_types] => Array
(
[name] => Post Types
[singular_name] => Post Type
[all_items_label] => All Post Types
[type] => post_type
[active_terms] => Array
(
[0] => Array
(
[name] => Practices
[value] => practice
))
)
)
[form_fields:Search_Filter_Active_Query:private] => Array
(
[search] => Array
(
[type] => search
[heading] =>
[placeholder] => Search …
[accessibility_label] => Enter Your Search Terms
)[_sft_category] => Array
(
[type] => category
[input_type] => checkbox
[heading] =>
[accessibility_label] => Select A Topic From The List
[all_items_label] => Topics
[show_count] => 0
[hide_empty] => 1
[hierarchical] => 0
[include_children] => 0
[drill_down] => 0
[sync_include_exclude] => 1
[combo_box] => 1
[no_results_message] =>
[operator] => and
[order_by] => default
[order_dir] => asc
[exclude_ids] =>
[taxonomy_name] => category
)[post_type] => Array
(
[post_types] => Array
(
[page] => 1
[practice] => 1
)[type] => post_type
[input_type] => select
[heading] =>
[all_items_label] => All Types
[accessibility_label] => Select Section Type From The List
[combo_box] => 0
[no_results_message] =>
))
[query_str:Search_Filter_Active_Query:private] => -1
[plugin_slug] => search-filter
[form_settings] => Array
(
[use_template_manual_toggle] => 1
[enable_taxonomy_archives] => 0
[enable_auto_count] => 0
[auto_count_refresh_mode] => 1
[auto_count_deselect_emtpy] => 0
[template_name_manual] => search.php
[page_slug] => advanced-search
[post_types] => Array
(
[practice] => 1
)[post_status] => Array
(
[publish] => 1
)[use_ajax_toggle] => 1
[scroll_to_pos] => 0
[pagination_type] => normal
[custom_scroll_to] =>
[use_relevanssi] => 1
[use_relevanssi_sort] => 1
[auto_submit] => 1
[display_results_as] => archive
[update_ajax_url] => 1
[only_results_ajax] =>
[ajax_target] => #search-filter-results-299
[ajax_links_selector] => .pagination a
[infinite_scroll_container] =>
[infinite_scroll_trigger] => -100
[infinite_scroll_result_class] =>
[show_infinite_scroll_loader] => 1
[results_per_page] => 9999999
[exclude_post_ids] =>
[field_relation] => and
[default_sort_by] => date
[sticky_posts] =>
[default_sort_dir] => desc
[default_meta_key] => _additional_settings
[default_sort_type] => numeric
[secondary_sort_by] => 0
[secondary_sort_dir] => desc
[secondary_meta_key] => _additional_settings
[secondary_sort_type] => numeric
[taxonomies_settings] => Array
(
[category] => Array
(
[include_exclude] => exclude
[ids] => 1
)[post_tag] => Array
(
[include_exclude] => include
[ids] =>
)[post_format] => Array
(
[include_exclude] => include
[ids] =>
)[luv_portfolio_categories] => Array
(
[include_exclude] => include
[ids] =>
)[luv_portfolio_tags] => Array
(
[include_exclude] => include
[ids] =>
))
[results_url] =>
)[cache_table_name] => wp_csf_search_filter_cache
[term_results_table_name] => wp_csf_search_filter_term_results
[field_values] => Array
(
[_sft_category] => Array
(
[0] => community-development
[1] => environment
)[post_types] => Array
(
[0] => practice
))
)
April 12, 2018 at 11:07 pm #171986In reply to: Display multiple terms
AnonymousInactiveTrevor, thanks again for spending time with me today. I really appreciated it.
Good news, I finally figured it out!
Here’s the happy code:
<?php global $searchandfilter; $args = array( "str" => '%2$s', "delim" => array(", ", " - "), "field_delim" => ', ', "show_all_if_empty" => false ); $sf_current_query = $searchandfilter->get(99801)->current_query()->get_array(); $sf_current_style_query = $searchandfilter->get(99801)->current_query()->get_fields_html(array("_sft_style", "_sft_name"),$args); $sf_current_cuisine_query = $searchandfilter->get(99801)->current_query()->get_fields_html(array("_sft_cuisine", "_sft_name"),$args); echo '<strong>Filters</strong>'; if ( empty($sf_current_query ) ) { echo ' • ' . "All" . "<br /><br />"; } else { echo ' • ' . $sf_current_query['_sft_category']['active_terms'][0]['name'] . ' • ' . $sf_current_query['_sfm_wpcf-location-city']['active_terms'][0]['name'] . ' • ' . $sf_current_style_query . ' • ' . $sf_current_cuisine_query; echo "<br /><br />"; } ?>
Cheers!
April 12, 2018 at 4:34 am #171733In reply to: Display multiple terms
AnonymousInactiveOkay, good news, I’m making progress…
This works for the array:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(99801)->current_query(); if ( empty($sf_current_query ) ) { echo '<strong>Filters</strong>' . ' • ' . "All" . "<br /><br />"; } else { $args = array( "str" => '%2$s', "delim" => array(", ", " - "), "field_delim" => ', ', "show_all_if_empty" => false ); echo '<strong>Filters</strong>' . ' • ' . $sf_current_query->get_fields_html(array("_sft_cuisine", "_sft_name"), $args); } echo '<br />'; ?>
Now I need to pull in the $key[‘active_terms’][0][‘name’] from the original code (it will display before the array).
That will give me what I’m after…
Filters • Florida • Caribbean, MexicanHow do I combine it?
March 30, 2018 at 5:23 pm #169245In reply to: Issue with get_fields_html
TrevorParticipantBut I don’t access it using get_fields_html. I do it like this:
global $searchandfilter; $sf_current_query = $searchandfilter->get(934)->current_query()->get_array(); $my_post_type = $sf_current_query[post_type][active_terms][0][value];
March 30, 2018 at 1:56 pm #169189In reply to: Accessing Field slug on search results
AnonymousInactiveI think I’ve sorted it thanks Trevor – sorry to mess you around!
If anyone else needs it, the code is as follows:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(1446)->current_query(); $array_data = $sf_current_query->get_array(); $typeOfSearch = $array_data["_sft_pwb-brand"]["active_terms"][0]["value"]; echo $typeOfSearch ; ?>
Where _sft_pwb-brand is the field you need, and 1446 is the ID of the search form.
March 30, 2018 at 11:35 am #169154In reply to: Issue with get_fields_html
TrevorParticipantAre you trying to get terms from the results array? This search shows other user posts that fetch data from the array:
https://support.searchandfilter.com/forums/search/sf_current_query+active_terms/
-
AuthorSearch Results