Forums › Forums › Search & Filter Pro › How do display the category in results?
Tagged: display categories, results
- This topic has 5 replies, 2 voices, and was last updated 6 years, 6 months ago by Anonymous.
-
Anonymous(Private) May 8, 2018 at 7:26 pm #176478
Hello,
I’m using a search form to show courses based on “course categories” of learndash LMS.
At the top of the results, I have this:
Found <?php echo $query->found_posts; ?> Result(s)
I’d like for it to say “Found X Result(s) in [CATEGORY]“. This [CATEGORY] is one of the radio buttons selected in the search filter.
How can I do this?
Thanks.
Trevor(Private) May 8, 2018 at 9:32 pm #176561This documentation might be useful for you:
https://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/
Anonymous(Private) May 9, 2018 at 2:19 am #176578Follow 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?
Anonymous(Private) May 9, 2018 at 5:03 pm #176709That 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.
-
AuthorPosts