Skip to:
Content
Pages
Categories
Search
Top
Bottom

Creating a custom search bar for groups

  • @luchadorvader

    Participant

    So right now I have a website where there two types of groups and I have a separate loops going on in separate page templates to see the list of those groups. But I want to create a search bar so the people can filter those groups based on the search term. Right now I have this code in here

    	if(!empty( $_REQUEST['s'] )) {
    		 $search_value = stripslashes( $_REQUEST['s'] );
    		 
    		 echo 'Search Value: '.$search_value;
    		 
    		 $meta_query['search_terms'] = $search_value;
    	 }
    	 ?>
    
     	<form action="http://website.com/group2" method="post" id="search-groups-form">
     			<label><input type="text" name="s" id="groups_search" placeholder="Search Groups..."></label>
     	</form> 
    	<?php if ( bp_has_groups($meta_query) ) : ?>

    And it sorta works as in certain key words will display a few results while other keywords will redirect it to a 404 page. I’m really lost and I unfortunately have a basic knowledge of GET and POST. I was wondering if anyone has advice on how to tackle this problem and if I’m going in the right direction. I don’t want to use the buddypress search groups form due to the fact that it will filter through all of the groups.

  • The topic ‘Creating a custom search bar for groups’ is closed to new replies.
Skip to toolbar