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

WordPress search seems to look into permalink (which is bad)

When we try searching for example.tld, then the default search query looks into the post title and content with: … (wp_posts.post_title LIKE ‘%example.tld%’) OR (wp_posts.post_content LIKE ‘%example.tld%’) … When we add an attachment or a local link, into the post content, we normally get the full url, for example: http://example.tld/wp-content/uploads/2015/05/image.jpg so I would think that … Read more

Search format not matching taxonomy query

Ok, the problem was with my radio buttons. <?php foreach( $regions as $region ) : ?> <label><input type=”radio” name=”region” value=”<?php echo $region->slug;?>” /><span><?php echo $region->name;?></span></input></label><br /> <?php endforeach;?> I have solved this problem by giving the radio buttons a name and value and not using any symbols in that name or value. It really was … Read more

WP_Query with custom post type search showing all results every time

It doesn’t look like you’re passing your search query in your WP_Query args. To do this on a custom search page try the following: Replace this: $the_query = new WP_Query(‘post_type=darpe-entries’); With this: global $query_string; $query_args = explode(“&”, $query_string); $search_query = array(); foreach($query_args as $key => $string) { $query_split = explode(“=”, $string); $search_query[$query_split[0]] = urldecode($query_split[1]); } … Read more

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