-
AuthorSearch Results
-
May 10, 2018 at 2:11 pm #176841
In reply to: Displaying results on load
TrevorParticipantAre you using our shortcode display results method? If so, edit the results.php file to use code like this:
global $searchandfilter; $sf_current_query = $searchandfilter->get(1024)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // your template archive code/loop OR results.php code here }
Change 1024 to the ID number of your form (from the form shortcode).
Make sure you are working on a copy of the results.php file in a search-filter sub-folder of your theme/child theme folder, and not the original in our plugin template folder.
May 9, 2018 at 5:03 pm #176709In reply to: How do display the category in results?
AnonymousInactiveThat didn’t work but the one from the link you provided earlier did work.
Here’s the code:
global $searchandfilter; $sf_current_query = $searchandfilter->get(71131)->current_query(); $args = array( "str" => '%2$s', "delim" => array(", ", " - "), "field_delim" => ', ', "show_all_if_empty" => false ); $result_title = $sf_current_query->get_fields_html( array("_sft_ld_course_category"), $args );
Thank you for your help with this.
May 9, 2018 at 10:12 am #176626In reply to: Hide results list by default
TrevorParticipantAs you are if you are using our shortcode display results method (and therefore our results.php template file), it needs to be edited to look like this:
global $searchandfilter; $sf_current_query = $searchandfilter->get(1024)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // your template archive code/loop OR results.php code here }
Change 1024 to the ID number of your form (from the form shortcode).
Make sure you are working on a copy of the results.php file in a search-filter sub-folder of your theme/child theme folder, and not the original in our plugin template folder.
May 9, 2018 at 6:08 am #176590In reply to: How do display the category in results?
TrevorParticipantInstead do this I think:
<?php $args = array( "str" => '%2$s', "show_all_if_empty" => false ); echo $sf_current_query->get_field_html(array("_sft_ld_course_category"),$args); ?>
May 9, 2018 at 2:19 am #176578In reply to: How do display the category in results?
AnonymousInactiveFollow up:
The string that is returned for this:
<?php echo $sf_current_query->get_field_string("_sft_ld_course_category"); ?>
(ld_course_category is the course category for the learndash lms plugin)
is:
Course Categories: All Course Categories
Is there a way the to get rid of the “Course Categories:” portion of the string so I’m just left with the actual result?
May 8, 2018 at 11:57 am #176320
TrevorParticipantThis would depend on the layout template being used for your page. That would depend on your theme or page builder/content plugin that you are using, or, if you are using our shortcode display results method and our results.php template file, it would look like this:
global $searchandfilter; $sf_current_query = $searchandfilter->get(1024)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // your template archive code/loop OR results.php code here }
Change 1024 to the ID number of your form (from the form shortcode).
May 7, 2018 at 11:22 am #176099
TrevorParticipantIt does indeed make sense. Here is how you would code what you want to do:
global $searchandfilter; $sf_current_query = $searchandfilter->get(1024)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // your template archive code/loop OR results.php code here }
Change 1024 to the ID number of your form (from the form shortcode).
May 6, 2018 at 9:02 pm #176058Topic: How to get all name terms of current filtered
in forum Search & Filter Pro
AnonymousInactiveHow to get all name terms of current filtered
I use current_query is found —- taxonomy [active_terms] —- in array but I dont to know
how to get term nameI need to do function like this
Thank you
April 23, 2018 at 8:53 pm #173884In reply to: Select Box Like Ted
AnonymousInactiveThanks!
Got it working using the links you supplied.
$sf_current_types_query = $searchandfilter->get(299)->current_query()->get_array(); $currentType=$sf_current_types_query['post_types']['active_terms'][0]['name']; if ( empty($currentType) ) { echo ''; } else { echo '<li>' . $sf_current_types_query['post_types']['active_terms'][0]['name'] . '<i class="fa fa-times"></i></li>'; } ?>
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
))
)
-
AuthorSearch Results
-
Search Results
-
How to get all name terms of current filtered
I use current_query is found —- taxonomy [active_terms] —- in array but I dont to know
how to get term nameI need to do function like this
Thank you