Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Search Exclude Archived

  • @potentdevelopment

    Participant

    Hello,

    I’m trying to figure out how I can modify the loop to that the search does not return any archived content. I’ve found this filter bbp_after_has_search_results_parse_args but I can’t seem to get very much information on how to remove archived content.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • @robin-w

    Moderator

    not quite sure what you mean by ‘archived’ content

    bbpress has statuses of

    public,
    private
    closed
    spam
    trash

    spam and trash depend on the user capability – so keymasters and moderators see these, but not participant level.

    @potentdevelopment

    Participant

    So how does one exclude the “closed” forums from bbpress search?

    Thanks

    @robin-w

    Moderator

    ‘closed’ in bbpress just means that the area cannot have new things added.

    If you want to have an old forum that is not seen by users, then make it hidden.

    @potentdevelopment

    Participant

    Hi Robin,

    We want it to be still visible, but we just want to exclude it from the search results. This is why I’m trying to figure out what to do with this filter: bbp_after_has_search_results_parse_args

    Thanks!

    @robin-w

    Moderator

    untested, but this should do it

    add_filter ('bbp_after_has_search_results_parse_args', 'my_function')
    
    my_function ($args) {
    	
    		// bbp_get_closed_status_id() REMOVED,
    		$post_statuses = array(
    			bbp_get_public_status_id(),
    			bbp_get_spam_status_id(),
    			bbp_get_trash_status_id()
    		);
    
    		// Add support for private status
    		if ( current_user_can( 'read_private_topics' ) ) {
    			$post_statuses[] = bbp_get_private_status_id();
    		}
    
    		// Join post statuses together
    		$args['post_status'] = implode( ',', $post_statuses );
    		
    return $args ;
    
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar