• Hi

    Is there a way to make search block, search the bbpress forum and not the site. Meaning apply the search functionailty from forum search to the search block of wordpress? and then not display the search block of the forum?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter hebhansen

    (@hebhansen)

    I came across this code that supposedly search forum only:

    /* Do not search pages, only posts and if there's a request from bbPress or Admin panel than ignore setting of post type */
    function search_filter($query) {
    if ($query->is_search && !is_admin() && !is_bbpress()) {
    $query->set('post_type', 'post');
    }
    return $query;
    }
    add_filter('pre_get_posts', 'search_filter');

    How can I activate this for the search block on forum but not for all other search blocks on site?

    Thread Starter hebhansen

    (@hebhansen)

    Or maybe this:

    function search_filter($query) {
    if ($query->bbp_is_search) {
    $query->set('post_type', array('post', 'forum', 'topic', 'reply'));
    } else if ($query->is_search) {
    $query->set('post_type', 'post');
    }
    return $query;
    }
    add_filter('pre_get_posts', 'search_filter');
    Thread Starter hebhansen

    (@hebhansen)

    Maybe relevant. I always get lost on Github, so I can’t even conclude the status.

    https://github.com/WordPress/gutenberg/pull/40585

    I’m curious: why are you going out of your way to break a native WordPress feature?

    Why would you not use the bbPress search shortcode… or the bbPress search block from the bbPress Style Pack plugin which you’re already using? Both can be placed anywhere just like the native search block so I’m genuinely curious to know why you seem bent on adapting the native search block instead!

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