Forums Forums Search & Filter Pro How do display the category in results?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Anonymous
    #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
    #176561
    Anonymous
    #176576

    Thank you, Trevor!

    Anonymous
    #176578

    Follow 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?

    Trevor
    #176590

    Instead 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);
    ?>
    Anonymous
    #176709

    That 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.

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