Site logo

[Support request] bbpress search in nav search bar

Home Forums Support [Support request] bbpress search in nav search bar

Home Forums Support bbpress search in nav search bar

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1806367
    Simon Wagemyr

    Hi!
    Is there any way to get the normal search to also show bbpress forum topics/replies?

    #1806399
    Leo
    Staff
    Customer Support

    Hi there,

    By normal search, are you referring to the navigation search or WordPress’ search widget?

    #1835068
    Melissa

    I can’t speak for the OP, but I’m trying to find the answer for including topics & replies in the navigation search…

    #1835070
    Simon Wagemyr

    Sorry for ghosting, I found something that works for now and got distracted.

    My current method is Relevanssi mod, but it feels like it shouldn’t be necessary.

    The goal is as Melissa described!

    #1835129
    Melissa

    @Simon- I finally got it.

    Add the following code to your functions.php

    add_filter( 'generate_navigation_search_output', function() {
        printf(  
            '<form method="get" class="search-form navigation-search" action="%1$s">
                <input type="search" class="search-field" value="%2$s" name="s" title="%3$s" />
                <input type="hidden" name="post_type[]" value="post" />
                <input type="hidden" name="post_type[]" value="topic" />
                <input type="hidden" name="post_type[]" value="reply" />
            </form>', 
            esc_url( home_url( '/' ) ), 
            esc_attr( get_search_query() ),   
            esc_attr_x( 'Search', 'label', 'generatepress' ) 
        ); 
    } );

    If you want to make it faster, either comment out or completely remove the reply line:

    // <input type="hidden" name="post_type[]" value="reply" />

    It’s still not superfast having to search all of the topics, particularly if you have a large database.

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