Intelligent Search Filtering

The problem with custom fields is that there is no relation between them so you can’t relate Suburbs to cities. A better way would be to create an hierarchical Custom Taxonomy so you can have a parent – child relation (like categories and sub categories). so: add_action( ‘init’, ‘create_locations_taxonomies’, 0 ); //create two taxonomies, genres … Read more

BuddyPress – Search members by name and also by username

Somebody on the BuddyPress support forums had this to say: I don’t recommend to change the core files of buddypress. The best way to do it is to write a custom code (I don’t know how to guide you). So if you don’t mind changing the core files, here is a quick way. Open /buddypress/bp-core/bp-core-classes.php … Read more

Search input area autogrow – how?

they’re using CSS3 transitions. <style type=”text/css”> #s { float: right; -webkit-transition-duration: 400ms; -webkit-transition-property: width, background; -webkit-transition-timing-function: ease; -moz-transition-duration: 400ms; -moz-transition-property: width, background; -moz-transition-timing-function: ease; -o-transition-duration: 400ms; -o-transition-property: width, background; -o-transition-timing-function: ease; width: 72px; } #s:focus { background-color: #f9f9f9; width: 196px; } </style> <input type=”text” class=”field” name=”s” id=”s” placeholder=”Search”>

Restrict Search Results to Post Author

Something like this should work: function my_search_filter($query){ if($query->is_search) $query->set(‘author’, get_current_user_id()); return $query; }; add_filter(‘pre_get_posts’, ‘my_search_filter’);

Search child pages from a specific page parent

I have no idea if this will work, but couldn’t you reference the post_parent in the query args? function SearchFilter($query) { if ($query->is_search) { //$query->set(‘post_type’, ‘page’); global $post; $query->set( ‘post_parent’, $post->ID ); } return $query; } add_filter(‘pre_get_posts’,’SearchFilter’); Again, completely untested. I’m not terribly familiar with using $query->set().

Search by meta_query

You should look into meta_query: $args = array( ‘meta_query’ => array( ‘key’ => ‘event_start_timestamp’, // the name of the meta ‘value’ => ’11/21/2011′, // the value to search for ‘compare’ => ‘>=’, //search for start dates bigger or equal to value ) ); $query = new WP_Query( $args );