Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

adds some categories to BP Default header search (dropdown options) in order to search within this categories...

View bp-search-post-cats.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
<?php
/*** based on http://buddydev.com/buddypress/making-buddypress-activity-searchable/ ***/
/* simply paste what follows in your functions.php file */
add_filter( 'bp_search_form_type_select_options', 'kendyman_seventeen_options', 10, 1);
function kendyman_seventeen_options( $options ) {
$args = array(
'orderby' => 'name', /* ou id ou count .. */
'order' => 'ASC', /* ou DESC */
'include' => array( 1, 5 ) /* list of category ids to include */
);
$cats = get_terms( 'category', $args );
foreach( $cats as $term ){
$options['cat-'.$term->term_id] = $term->name;
}
return $options;
}
add_filter('bp_core_search_site', 'kendyman_seventeen_search_by_cat_url', 10, 2);
function kendyman_seventeen_search_by_cat_url( $url, $search_terms ){
$search_which = $_POST['search-which'];
if( strpos( $search_which, 'cat-' ) !== false ) {
$search_query = str_replace('-', '=', $search_which );
$url = site_url( '/?s='. urlencode( $search_terms ) .'&'. $search_query );
}
return $url;
}
?>

I wish display a new post type, is there a way? Thanks :*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.