Forums Forums Search & Filter Pro How to display filtered results count and filters?

Viewing 9 posts - 1 through 9 (of 9 total)
  • Anonymous
    #209219

    Hello!

    I want to display the filtered results count for example:

    Found 15 results…

    Also I want to display the filters, for example:

    Selected filters:

    Custom category, sort, etc…

    I tried with these, but not working for me:
    https://searchandfilter.com/documentation/accessing-search-data/

    Trevor
    #209267

    What Display Results Method does your form use?

    Anonymous
    #209271

    Im using custom display method display method.

    Trevor
    #209277

    Thanks for that. How is it linked to the results? Are you using a plugin to display results, or did you edit a PHP template page (to add our filter argument to the query)?

    Anonymous
    #209279
    This reply has been marked as private.
    Anonymous
    #209327

    Any help?

    Trevor
    #209333

    I am sorry for the delay. I am working my way through a backlog and I answer posts is oldest last touched order, so yours was still another two or three down the list when you sent that last reply. The standard WordPress would, with your wp_query() array name, look like this:

    Found <?php echo $query_all->found_posts; ?> Results

    As to showing the filters, this is more complex. It would require custom coding when using the current version of Search & Filter Pro. You can access the filter terms though, but would need further PHP work to display them. To fetch the search terms, the https://searchandfilter.com/documentation/accessing-search-data/ guide is basic but you can extend the idea to grab lots of other data. If you have other filters, then it becomes a little more complex, but I can give you links. This thread might help you:

    https://support.searchandfilter.com/forums/topic/accessing-field-slug-on-search-results/

    … and this search will give similar threads I think:

    https://support.searchandfilter.com/forums/search/sf_current_query+get_array+field+%5Bvalue%5D/

    Note, if you are using Ajax refreshing of the results, any PHP needs to be inside the Ajax Container, or it will not update.

    Anonymous
    #209339

    Thank you so much. Now Im displaying the result counter also Im displaying the filters.

    <?php		
    		global $searchandfilter;
    	$sf_current_query = $searchandfilter->get(840)->current_query();
    		$args = array(
    				"str" 					=> '%2$s', 
    				"delim" 				=> array(", ", " - "), 
    				"field_delim"				=> ', ', 
    				"show_all_if_empty"			=> false 
    			);
    			
    			echo $sf_current_query->get_fields_html(
    				array("_sft_category"), 
    				$args
    			);
    
    ?>

    My result is

    Genre1, Genre2, Genre3, etc…

    How I can “put” this array in div or class?

    Trevor
    #209353

    Instead of this:

    echo $sf_current_query->get_fields_html(array("_sft_category"), $args);

    this:

    $my_category_array = $sf_current_query->get_fields_html(array("_sft_category"), $args);

    And then manipulate, I think. For this you would need to find some snippets, on a site like stackexchange.

Viewing 9 posts - 1 through 9 (of 9 total)