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

I’m trying to expand the scope of the default WP search algorithm. What am I doing wrong?

Add this temporarily to your functions.php. It will break things but you can see the WHERE clause. Be sure to remove it because things won’t work right if you leave it there. function dump_where($w){ var_dump($w); } add_filter(‘posts_where’,’dump_where’); The first thing you should notice is that the % signs get escaped. Remove those and WordPress will … Read more

Search in post title and custom fields

Here is one idea using the posts_clauses filter: function search_posts_clauses($clauses, $query){ if(!is_admin() && $query->is_main_query() && $query->is_search()){ global $wpdb; // replace post_content with meta_key and meta_value: $searchterms = explode(” “,get_query_var(“s”)); foreach($searchterms as $searchterm){ $from = sprintf(“{$wpdb->posts}.post_content LIKE ‘%%%s%%'”, $searchterm); $to = sprintf(“{$wpdb->postmeta}.meta_key = ‘cities’ AND {$wpdb->postmeta}.meta_value=”%s” “, $searchterm); $clauses[“where”] = str_replace($from, $to, $clauses[“where”]); } $clauses[“join”] = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)