Skip to:
Content
Pages
Categories
Search
Top
Bottom

Plugin, snippet, hack to include bbpress topics in wordpress search


  • pazzaglia
    Participant

    @pazzaglia1

    I’ve searched these forums and found mostly technical replies from developers (I’m semi-technical so making up some code from scratch and knowing where to stick it is out of my league).

    I’ve tried “Everything Search” which does not index topics.

    I’ve tried free “Relevanssi” search which has a check-box for tpics but shows them as “not public” (https://wordpress.org/support/topic/does-relevanssi-search-include-bbpress-forms-topics-and-replies?replies=3)

    I’ve tried various snippets that I found via google search – each with additions to functions.php a couple don’t work, and a third actually works, but it blanks-out the topic pages (the page is still there but the text of the topic and replies is missing).

    I’ve enabled Jetpack “omnisearch” which has no options but still doesn’t show the topics in the search results.

    Please point me to where I can find information to modify my WordPress, Theme, or BBPress installation so that search results from the main form include topics!!!

    Thank you!!!

    L

    P.S. My website http://www.hippressurecooking.com – I have lots of forum topics discussing Christmas Puddings but if you search for “pudding” on the main website all you get is the posts & pages with the word “pudding” and none of the topics with valuable info.

    P.P.S. I have search enabled in the forums, but in addition to that I would like the results all in one place from the basic WordPress search that shows up on every page.

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

  • Robkk
    Moderator

    @robkk

    you can place this code into your child themes functions.php file

    
    /**
     * Include bbPress 'topic' custom post type in WordPress' search results
     */
    function ntwb_bbp_topic_cpt_search( $topic_search ) {
    	$topic_search['exclude_from_search'] = false;
    	return $topic_search;
    }
    add_filter( 'bbp_register_topic_post_type', 'ntwb_bbp_topic_cpt_search' );
    
    /**
     * Include bbPress 'reply' custom post type in WordPress' search results
     */
    function ntwb_bbp_reply_cpt_search( $reply_search ) {
    	$reply_search['exclude_from_search'] = false;
    	return $reply_search;
    }
    add_filter( 'bbp_register_reply_post_type', 'ntwb_bbp_reply_cpt_search' );

    got the code from here, i see you also commented on it to 🙂

    https://gist.github.com/ntwb/7363a1de1184d459f0c3


    undergroundnetwork
    Participant

    @undergroundnetwork

    I’ve added to the code as the above code does not search for Forum Titles, this code includes titles in the search as well:

    
    /**
     * Include bbPress 'topic' custom post type in WordPress' search results */
     
    function ntwb_bbp_topic_cpt_search( $topic_search ) {
    	$topic_search['exclude_from_search'] = false;
    	return $topic_search;
    }
    add_filter( 'bbp_register_topic_post_type', 'ntwb_bbp_topic_cpt_search' );
    
    /**
     * Include bbPress 'forum' custom post type in WordPress' search results */
    
    function ntwb_bbp_forum_cpt_search( $forum_search ) {
    	$forum_search['exclude_from_search'] = false;
    	return $forum_search;
    }
    add_filter( 'bbp_register_forum_post_type', 'ntwb_bbp_forum_cpt_search' );
    
    /**
     * Include bbPress 'reply' custom post type in WordPress' search results  */
    
    function ntwb_bbp_reply_cpt_search( $reply_search ) {
    	$reply_search['exclude_from_search'] = false;
    	return $reply_search;
    }
    add_filter( 'bbp_register_reply_post_type', 'ntwb_bbp_reply_cpt_search' );
    

    pazzaglia
    Participant

    @pazzaglia1

    Thanks, @Robkk I didn’t know how to use that – I didn’t realize it was as easy as adding it to my functions file.

    Thanks for the addition @undergroundnetwork!

    Since I posted I’ve been using this outdated-but-it-works plug-in.
    https://wordpress.org/plugins/search-bbpress/

    Although that plug-in, works, it also displays shows links to slides that I have on the homepage in the results – not a big deal as I don’t have too many slides but I’d rather that not happen.

    In an effort to reduce plug-ins I’m going to give this code a shot.

    Ciao,

    L


    pazzaglia
    Participant

    @pazzaglia1

    I just installed this bit of code and it works GREAT!!

    Now I know when I find random code around it’s expected to be added to functions.php as well.

    THANK YOU SO MUCH & HAPPY NEW YEAR!

    Ciao,

    L

    P.S. I love that the forums show-up as well. Except now I’ll have to change the name to “xyz Forum” so it’s clear what it is in the search results.


    pazzaglia
    Participant

    @pazzaglia1

    Unfortunately, with the upgrade to WordPress 4.x these little snippets no longer work – I read elsewhere that bbpress search had some updates which likely render these snippers useless. : (

    If anyone has the updated code, I would really appreciate it!!

    Ciao,

    L


    Robkk
    Moderator

    @robkk

    @pazzaglia1

    is it just the search or is it bbPress entirely??

    As long as you have the latest bbPress too it should work fine.

    usually users that have problems with bbPress when upgrading to WP 4 , we usually recommend these two plugins to help solve their issue.

    bbpress wp4 fix

    bbpress wp4 fix2

    you can also go through the normal troubleshooting to identify an issue.

    bbpress.org/forums/topic/before-posting/


    pazzaglia
    Participant

    @pazzaglia1

    No, bbpress is up and running – just the search with the above code added to my functions file no longer shows bbpress topics as part of the results. Will click on the recommended fix links above to see if either fix will bring the results back.

    Thanks & Happy Easter!

    Ciao,

    L


    pazzaglia
    Participant

    @pazzaglia1

    I installed both “fixes” and the search still does not include bbpress topics. For example there are several discussions on dog food and pressure cooker puddings in the forums so if I search for “dog” or “pudding” those topics should be included in the results, but they are not.

    Ciao,

    L


    Robkk
    Moderator

    @robkk

    @pazzaglia1

    you are running into a couple issues.

    As for some users i can see their profile leads to a 404 too.

    create me an Admin account and send me the login details by email so i can see what plugins you are using , if there is a code snippet causing an issue, your theme , or something else.

    when im done helping you , you can delete the account.

    Contact


    Robert.S
    Participant

    @roberts-1

    Thanks a bunch for the code, both @robkk and @undergroundnetwork!

    I’m running Avada theme, with latest WordPress 4.2.1 and BBPress 2.5.7 and this works perfectly.

    Seems like this *should* be an option in WordPress when BBPress is installed: “Check the box to include Forum Topics and Replies in the sitewide search”. Would be a helpful addition.

    Luckily we have this resource, so thanks again for the code snippets.


    caniwigirl
    Participant

    @caniwigirl

    Nice to see that other people would like to see this as part of the standard set-up as @roberts-1 says… I am running the same versions using Momizat’s ‘Goodnews’ theme

    I’ve just tried @undergroundnetwork ‘s code and it works great for me as an admin… but for some reason, the other users with lower levels of access, don’t get the same result – they only get WordPress results, none from bbPress.

    Any ideas why? I’d really like to just have one search that does it all instead of one for forums and another for blogs etc.

    Cheers


    davidddn
    Participant

    @davidddn

    Same issue – bbpress topic and reply search results only display for admin. Latest WP and bbpress.


    Sam Rohn
    Participant

    @sam-rohn

    the bbpress search code posted above by robkk works fine for me with wordpress 4.2.2 + bbpress 2.5.8, shows expected bbpress topics and replies in wp search results for admins, non admin members, and non logged in users

    also respects posts hidden by s2member bbpress level restrictions

    sam


    davidddn
    Participant

    @davidddn

    I’ve tried adding ALL admin capabilities and it has no effect on the search results. Changing user role to administrator does provide results.


    Sam Rohn
    Participant

    @sam-rohn

    also respects posts hidden by s2member bbpress level restrictions

    i was mistaken, topics hidden by s2member restrictions are hidden, but replies are not hidden in search results when using this snippet

    davidddn, you may have another plugin or theme function interfering with this search code, so try testing with default wp theme and disable other plugins etc

    otherwise, including bbpress in standard wp search results as a standard option in bbpress would be great

    sam


    AilyRoot
    Participant

    @ailyroot

    Hi
    we run WP 4.3 and bbpress 2.5.8
    This codes does allow both admin and normal user to search for both wp and forum contents fine.

    However normal user with no permission to certain forum could search for those articles in hidden forum too! and they could view the full fine from click link on search results, this is privacy alert!


    Ingridlin
    Participant

    @ingridlin

    Hi, I just add the bbpress search code posted above by robkk, and it works too fine Some private topics are also show up. How could I use this search function but not include the private topic. Or maybe it could only shows the topic name but not content. Thanks


    dtmember
    Participant

    @dtmember

    Hi, I just add the bbpress search code posted above by robkk, and it works too fine Some private topics are also show up. How could I use this search function but not include the private topic. Or maybe it could only shows the topic name but not content. Thanks

    Is there anyone might able to solve this?


    siparker
    Participant

    @siparker

    code works fine for me to include topics posts and replies but same as above it shows private replies.


    khunmax
    Participant

    @khunmax

    BUMP

    I can confirm that if you install the above code in your functionality plugin and then use the
    WP NICE SEARCH plugin set to all you can display your bbpress content in a nice ajax drop down in your sidebar.

    Nice Search also has the option to limit the search parameters by configuring its shortcode:

    [wpns_search_form only_search=”my_custom_post_type”]

    I want to use this shortcode in the sidebars for my forum conent and limit the search to just Forums, Topics and Replies (no WP stuff included). However, I can not figure out what I should put in the NICE SEARCH shortcode as the BBpress custom post types.

    I have tried both of the following as a trial but they didn’t work:

    [wpns_search_form only_search=”bbp_register_topic_post_type”]

    and

    [wpns_search_form only_search=”ntwb_bbp_topic_cpt_search”]

    Can anyone assist me with what the correct format of the BBpress custom post type(s) that I should be entering into the NICE SEARCH short code.

    Thanks in advance for any assistance that is offered.

    Kind Regards

    Max

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