Skip to:
Content
Pages
Categories
Search
Top
Bottom

Exclude the replies from search results


  • thinkercorner11
    Participant

    @thinkercorner11

    Hello there!

    I want to exclude the replies from the search results, but I don’t know where I can change it (maybe a simple solution to put true to false?) or can anyone help me to figure out a code for the function.php in the child theme?

    Greetings

Viewing 5 replies - 1 through 5 (of 5 total)

  • Robin W
    Moderator

    @robin-w

    this code should do that

    add_filter ('bbp_before_has_search_results_parse_args' , 'rew_topics_only') ;
    
    function rew_topics_only ($args) {
    	$args['post_type'] = bbp_get_topic_post_type() ;
    return $args ;
    }

    Put this in your child theme’s function file –

    ie wp-content/themes/%your-theme-name%/functions.php

    where %your-theme-name% is the name of your theme

    or use

    Code Snippets


    thinkercorner11
    Participant

    @thinkercorner11

    Thanks for the fast reply! First I needed to figure some things out, because I had configured my Childtheme not in a proper way, but now it works, so thanks.

    Is it possible also to include forums into the search results, not only topics?


    Robin W
    Moderator

    @robin-w

    add_filter ('bbp_before_has_search_results_parse_args' , 'rew_topics_only') ;
    
    function rew_topics_only ($args) {
    	$args['post_type'] = array (bbp_get_topic_post_type(), bbp_get_forum_post_type()) ;
    return $args ;
    }

    thinkercorner11
    Participant

    @thinkercorner11

    Thanks for the help!


    Robin W
    Moderator

    @robin-w

    great – glad you are fixed !

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar