SQL query to get adjacent posts from search query

Although this is possible, it really is not viable. I’ve done a lot of research on this subject, but could not find a straight forward answer I went and had a look at the WP_Query class for a possible solution, and I came to the conclusion that what I was trying to accomplish would not … Read more

Strange Search Queries in Apache Status

I’m sure you’ve googled ‘khabarnaak’ – it’s a Pakistani talk show. It’s more likely to be an automated scraper trying to find content rather than an attack. The request does not look like it has been crafted for a WordPress site. Two ways to stop it are: Block the IPs making the request. Add ‘Deny … Read more

Sitelinks Search Box in Google and urlencoded search string

I can confirm that url-decoding the search query is the correct approach. In fact, it is done in WordPress core for the search parameter of WP_Query but not when the search string is from a $_GET request as it is seen in WP_Query::parse_search() method, wp-includes/query.php#L2061 (WP 4.2.2): if ( empty( $_GET[‘s’] ) && $this->is_main_query() ) … Read more

Making a list of post tags in string

You’re using get_the_tags() incorrectly. It does not return an array of tag names. It returns an array of tag objects. Each tag object does contain the tag’s name (along with other data), but you can’t use implode() on that result. I used your original code just adding a step to put the tag object’s name … Read more

How to change users smart quotes to dumb quotes in search bar?

Try this. It’s a function that will filter the search query and replace any smart quotes with their “dumb” equivalent. <?php /** * Filter smart quotes out of a search query. * Replace them with “dumb” quotes. * * @param WP_Query $query Instance of WP_Query. */ function filter_search_smart_quotes( $query ) { if ( $query->is_search() ) … Read more

intellisense in wp search

So you want more general autocomplete, rather than something specific (like blog tags for example)? If you use (or will consider using) Google Custom Search (which is very popular option to replace native WP search), they made it quite easy to enable native autocomplete with it. See: Autocompletion of queries in Custom Search Control over … Read more

Display title for search engine visitors

I just ran a test on my hosted dev site. I ran the following: echo ‘<pre>’; global $wpdb; print_r($wpdb); print_r($GLOBALS); echo ‘</pre>’; There was no ‘wp_query’, ‘[q]’, or ‘search’ variables to be found. Note that I was not able to search this through a search engine as it’s not web accessible. Just to give you … Read more

Display Categories in Search Results

What you basically want to do is to change the SQL query being done to group the result of the query by category The code taken from here groups by performing a sort by category. You can place the following code in your themes search.php file <?php add_filter(‘posts_join’, create_function(‘$a’, ‘global $wpdb; return $a . ” … Read more