stoffer_dev (@stoffer_dev)

Forum Replies Created

Viewing 10 replies - 1 through 10 (of 10 total)
  • @stoffer_dev

    Participant

    Thanks again 🙂

    @stoffer_dev

    Participant

    In a custom plugin I just made 🙂

    @stoffer_dev

    Participant

    I found a way to put it in a plugin 🙂

    I Thought I would have to hook into ‘plugins_loaded’ like so:

     add_action( 'plugins_loaded', 'bbpress_overwrite' );
    
     function bbpress_overwrite() {
         add_filter ('bbp_before_has_search_results_parse_args', 'rew_amend_search') ;
     }
    
    function rew_amend_search ($args) {
    	$args['post_type'] =  bbp_get_topic_post_type() ;
    return $args ;
    }

    But for some reason this was enough: ?

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

    @stoffer_dev

    Participant

    Really nice. Worked like a charm 🙂 !

    Can I put this in a custom plugin instead of functions.php ?

    @stoffer_dev

    Participant

    If I could put the solution in a custom plugin it would be really awesome 🙂

    @stoffer_dev

    Participant

    No worries 🙂 I am just happy to get help.

    I want to change the function: bbp_has_search_results. Where I replace:

    $default_post_type = array( bbp_get_forum_post_type(), bbp_get_topic_post_type(), bbp_get_reply_post_type() );

    With:

    $default_post_type = array(bbp_get_topic_post_type(), bbp_get_reply_post_type() );

    @stoffer_dev

    Participant

    Can I also override files in the “includes” folder (bbpress/includes/search/template.ph) in a child theme?

    @stoffer_dev

    Participant

    The problem is, using the template solution will get overwritten when I update the the bbPress plugin…:(

    @stoffer_dev

    Participant

    I put this:

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

    in my wp-content/themes/<ThemeName>/functions.php

    But Forum names (“bbp_get_forum_post_type()”) are still included in the search results on the frontend.

    Only editing “plugins/bbpress/includes/search/template.php” works 🙂

    @stoffer_dev

    Participant

    Hi Robin W 🙂

    The above solution does not work in 2019. Is there a new way to only search topics and replies as of now ?

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