Search Results Customization

You can modify any query in pre_get_posts filter. So your code could looks like this: function prefix_modify_search( $query ) { if( $query->is_search && $query->is_main_query() ) { $search = $query->get( ‘s’ ); $search .= ‘*’; $query->set(‘s’, $search); } } add_action( ‘pre_get_posts’, ‘prefix_modify_search’ ); Note that the query parameter is passed as reference so you don’t need … Read more

I’ve messed up the admin search functionality. Help!

You can check if is_admin or not in the first line of the function add_filter(‘posts_where’, ‘advanced_search_query’ ); function advanced_search_query( $where ) { if(is_admin()){ return $where; } if( is_search() ) { global $wpdb; $query = get_search_query(); $query = like_escape( $query ); // include postmeta in search $where .=” OR {$wpdb->posts}.ID IN (SELECT {$wpdb->postmeta}.post_id FROM {$wpdb->posts}, {$wpdb->postmeta} … Read more

Insert DIV container below 1st search result

You should be able to do that with: /** * Setup a custom hook before the second post on the search page */ add_action( ‘the_post’, function( $post, \WP_Query $q ) { if( $q->is_search() && $q->is_main_query() && 2 === $q->current_post ) { do_action( ‘wpse_before_second_post_in_search’ ); } }, 10, 2 ); /** * Inject a Div after … Read more

Searching on my blog is not working

It looks like you aren’t actually grabbing the search query in your form. You need to include value=”<?php the_search_query(); ?>” in your input field. Here is a link to the docs for the search form. I think what you’re looking for is under the ‘Theme Form’ heading.

How to Search Users on the Base of Latitude and Longitude in Users meta_key and meta_value

Well, there is a pretty confusing way to get the points which are in the radius of another point. $center_lat = $_GET[“lat”]; //insert the lat of where you are $center_lng = $_GET[“lng”]; //insert the lng of where you are $radius = $_GET[“radius”]; //insert the radius of KM that you want to search $multiplier=3959; //miles $multiplier=($multiplier*1.609344); … Read more

Can I set up a search box that uses fields?

If you want to do this from scratch: There’s two theme template files you can use for this: searchform.php – this is rendered when you add a search widget to a sidebar. Add your dropdown boxes here. search.php – this is where you’d write your custom Query using the submitted values from the form. The … Read more