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

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 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 );

Search returns everything if search term has a space

Chances are it’s searching using the ‘OR’ operand, which for will pull up everything that has those common words – ‘of the’. There are a number of alternate search plugins for WordPress – we’ve had great results (pun intended) using Relevanssi.

How to insert meta keyword to search result page

that is relatively easy. you can add this to your theme’s functions.php file add_action(‘wp_head’, ‘add_meta_tags’); function add_meta_tags(){ if(is_search()){ $search_keyword = get_search_query(); echo ‘<meta name=”META_NAME” content=”META TESTING” />’; } } you may change echo ‘<meta name=”META_NAME” content=”META TESTING” />’; as you want to output the meta tags. however, your theme needs to call wp_head(); for this … Read more

Use wordpress search to display results within a post

WP_Query accepts a search parameter, ‘s’. Hence, you can just do this: <?php $related_posts = new WP_Query( ‘s=” . the_title_attribute( “‘, ”, 0 ) ); if( $related_posts->have_posts() ) : while( $related_posts->have_posts() ) : $related_posts->the_post(); // STUFF endwhile; endif; wp_reset_postdata(); ?> While we’re here, note the use of WP_Query which is more appropriate for a secondary … Read more