Tag Info

Hot answers tagged

3

Step 1 Start by making an Advanced Search Form with which you want your user will interact with the website, and save it with a name (i.e. I saved it as advanced-searchform.php — but don't save it with searchform.php then it'll replace the WordPress' default search form): <form method="get" id="advanced-searchform" role="search" action="<?php ...


1

You can use pre_get_posts action to exclude categories from search query. function wcs_exclude_category_search( $query ) { if ( is_admin() || ! $query->is_main_query() ) return; if ( $query->is_search ) { $query->set( 'cat', '-22, -21' ); } } add_action( 'pre_get_posts', 'wcs_exclude_category_search', 1 ); You should paste this ...


1

Since WP 3.7 there is a filter "posts_search_orderby" that allow to set the ordering for search. To be sure that filter works as expected set "orderby" to "relevance". add_action( 'pre_get_posts', function( $query ) { if ( $query->is_search() ) { $query->set( 'orderby', 'relevance' ); } } ); and then, assuming your profiles CPT slug is ...


1

Enter your form where ever you plan to display it /**** The Form ****/ <form name="searchcars" method="get" action="http://yourdomain.com/your-page-template-slug"> <label>Search</label> <input type="text" name="searchfor"> <label>Location</label> <Select name="location"> <?php ...



Only top voted, non community-wiki answers of a minimum length are eligible