Creating a Search Array From Multiple Tables

You’ve got the right idea. If you get an array of country IDs within a region, you can pass that array to a meta query IN comparison: $country_ids = array(1,2,3); // this would be the result from fetching countries associated with a region. $args = array( ‘posts_per_page’ => -1, ‘meta_query’ => array( array( ‘key’ => … Read more

WordPress custom search url

It’s easy. Just add this hook for template_redirect action and it will redirect your search queries to nice url: function wpse8170_search_url_redirect() { if ( is_search() && !empty( $_GET[‘s’] ) ) { wp_redirect( home_url( “/something/” . urlencode( get_query_var( ‘s’ ) ) ) ); exit; } } add_action( ‘template_redirect’, ‘wpse8170_search_url_redirect’ ); Add to your .htaccess file: # … Read more

Get search.php results in header.php?

Now, is it possible to check if page is the search page is_search() AND what’s the search string is_search() AND print get_query_var( ‘s’ ) AND how many posts were found? is_search() AND print $GLOBALS[‘wp_query’]->number_posts() … or if you got a custom query… $my_query = new WP_Query( array( /* whatever args */ ) ); is_search() AND … Read more

How to query post like normal search would do. within search.php page

This is what i did: I run another query without pagination like this: $newQuaryVars=”&posts_per_page=99999999999999&post_type=post”; $posts = query_posts($query_string .$newQuaryVars); $categoriesList = array(); $categoriesAmounts = array(); Then in the while have posts i did the following: while ( have_posts() ) : the_post(); $postCategories = get_the_category(); if($postCategories){ foreach($postCategories as $categoryInfo) { $categoriesAmounts[$categoryInfo->term_id][‘amount’]++; $categoriesList[$categoryInfo->term_id] = array( ‘name’ => $categoryInfo->name, … Read more

Filter custom post type using multiple taxonomy dropdowns

Right, seems a little empty here but I figured out the problem myself, again. The trick was to have empty values in the $output variables. So $output .=”<option value=””>Select taxonomy #1</option>”; NOT $output .=”<option value=”#”>Select taxonomy #1</option>”; This is how you can create two dropdown menus and filter out your posts using your custom taxonomies. … Read more