Custom search for a custom post type in WordPress

Change operator to IN: array( ‘taxonomy’ => ‘features’, ‘terms’ => $feature_slugs, ‘field’ => ‘slug’, ‘operator’ => ‘IN’, ), That will query posts that have any of the terms in $feature_slugs, rather than all of the terms, which is what AND does. Also, I can see you’re using the POST method for this search. That type … Read more

Custom Post Type WP_Query with filters and search

This is what I ended up with: $specialty_terms = get_terms(‘specialty’); $specialty_term_ids = wp_list_pluck($specialty_terms, ‘slug’); $location_terms = get_terms(‘locations’); $location_term_ids = wp_list_pluck($location_terms, ‘slug’); if( isset($_GET[‘docname’]) ): $name_search = $_GET[‘docname’]; else: $name_search = “”; endif; if( isset($_GET[‘specialty’]) && $_GET[‘specialty’] !== ”): $specialty = $_GET[‘specialty’]; else: $specialty = $specialty_term_ids; endif; if( isset($_GET[‘location’]) && $_GET[‘location’] !== ”): $location = $_GET[‘location’]; … Read more

How do i search post by jquery datepicker?

I think it’s better to use date_query as argument, like so : $query = new WP_Query( ‘year=2012&monthnum=12&day=12’ ); or: $args = array( ‘date_query’ => array( array( ‘year’ => 2012, ‘month’ => 12, ‘day’ => 12, ), ), ); $query = new WP_Query( $args ); Source : https://codex.wordpress.org/Class_Reference/WP_Query

how to disable autocomplete search on wpLink?

OP linked it in a comment above, but here’s the code used. Note This doesn’t actually disable autocomplete, it simply removes all of the results before they’re displayed (and I added some CSS to hide the loading icon). They’re still fetched by WP, just overridden with an empty array. add_filter( ‘wp_link_query’, ‘remove_results_from_link_builder_autocomplete’, 10, 2 ); … Read more

Search only for posts with specific metadata?

Quick question…which case applies? If you just need a query for today’s date being between two pieces of metadata, I’d create a widget running a fairly straight forward WP_Query and outputting the posts. If you are asking for the user to input a date to search, I’d probably still use a widget but would use … Read more