Created
September 26, 2014 07:13
-
-
Save ntwb/7363a1de1184d459f0c3 to your computer and use it in GitHub Desktop.
bbPress - Include Topics and Replies in WordPress Search Results
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: bbPress - Include Topics and Replies in WordPress Search Results | |
Plugin URI: https://gist.github.com/ntwb/7363a1de1184d459f0c3 | |
Description: bbPress - Include Topics and Replies in WordPress Search Results | |
Version: 0.1 | |
Author: Stephen Edgar - Netweb | |
Author URI: http://netweb.com.au | |
*/ | |
/** | |
* 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' ); |
This is exactly what I was looking for. Thank you very much.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks so much for this snippet. Very helpful, although it does not appear to respect a forums' privacy. If the content cannot be viewed by the current user, it probably shouldn't appear in search results.
I just started looking at this, but I imagine we could grab the parent forum and check to see if the current user has permission to view it.
EDIT: Sorry, just realized that all this is doing is making the post types available to search and has nothing to do with the results. Carry on.