Custom URLs in Custom Search Results

You can get close to what you want by using the template_redirect hook. function my_custom_search_url_rewrite() { if ( is_search() && ! empty( $_GET[‘s’] ) ) { wp_redirect( home_url( “/search/” ) . urlencode( get_query_var( ‘s’ ) ) ); exit(); } } add_action( ‘template_redirect’, ‘my_custom_search_url_rewrite’ ); Then you can use a URL like http://domain.com/search/category+location/. If you then … Read more

How can I replace the search results displayed by WordPress?

You can use template_include filter hook to check if the current call is a search call and if so include your own template in which you can do what ever you want : add_filter(‘template_include’,’my_custom_search_template’); function my_custom_search_template($template){ global $wp_query; if (!$wp_query->is_search) return $template return dirname( __FILE__ ) . ‘/my_search_template.php’; }

WooCommerce search products between price range using WP_Query

The solution: $query = array( ‘post_status’ => ‘publish’, ‘post_type’ => ‘product’, ‘posts_per_page’ => 10, ‘meta_query’ => array( array( ‘key’ => ‘_price’, ‘value’ => array(50, 100), ‘compare’ => ‘BETWEEN’, ‘type’ => ‘NUMERIC’ ), ), ); $wpquery = WP_Query($query); // return 10 products within the price range 50 – 100

How to implement search suggestions into search bar?

This question is too broad to answer in detail, but here is how I would approach this: Given that WP’s native search is slow, we can rule out using this to get intermediate results while the visitor is typing. Unless we have a lightning fast dedicated server. So, this means we will have to build … Read more

How do I override the search template in a plugin?

You can use template_include filter hook add_filter(‘template_include’,’my_custom_search_template’); function my_custom_search_template($template){ global $wp_query; if (!$wp_query->is_search) return $template; return dirname( __FILE__ ) . ‘/my_search_template.php’; } /*UPDATE: there was a missing “;” after $template*/

Search page pagination does not work

<form method=”post” action=”<?php bloginfo(‘url’); ?>/customsearch.php” class=”search-form” role=”search”> … </form> customsearch.php in content : http://pastebin.com/mxVPphXa customsearch.php should be here: yoursite.com/dir/customsearch.php