You will need to create two queries. The first will be one that pulls all of the custom post types in the search query.
$args = array(
'post_type' => YOUR-POST-TYPE,
'posts_per_page' => '-1',
's' => get_search_query(),
);
$sort_query = new WP_Query($args);
$included_results = array();
You will then have to probably print out your results so you can find where the zip code is in the array.
Run the loop, checking if the zip is in your zip code array (in_array()
) and add the id to the included results array (ex: $included_results[] = $post->ID
)
Next, you will want to end and reset the query, and create a new query using the same args as before, but adding 'post__in' => $included_results
Related Posts:
- filter search result with custom post type meta key
- How Do I Use WP_Query to Run This Database Query as Search Result?
- Building an Advanced Search (text, tags, category, custom fields) – Getting the wrong SQL query
- Custom search for custom post meta with pre_get_posts interferes with WP search
- Custom post type search using $_SESSION and pre_get_posts
- Prevent A Specific Custom Post Type Showing In WP Search Results Page
- Custom Post Search
- pre_get_posts not firing at all
- Include custom taxonomy term in search
- Searching multiple custom post types and pages
- AJAX search on post pages by custom post type
- How can I change the admin search posts fields?
- Development of a WordPress Search Plugin – Best Practices
- Admin Area Custom Type Search By Meta Fields Without Title & Content
- Simple way to search custom-post types only
- Pushing a custom post type to the top of the search results
- $query->set in pre_get_posts is unintentionally affecting the backend
- Search that will look in custom field, post title and post content
- Add Custom Post Type to Current Query
- Returning search results by relevance, including Custom Post Types
- How to replicate some of Drupal Views functionality in WordPress?
- How to show more posts on an archive page?
- Include post id[s] into WP_Query()
- Pre get posts for single post
- Seperating Custom Post Search Results
- Exclude from search all custom posts which are NOT in a taxonomy term
- Pre_get_posts Gives 404 on Custom Post Type
- Search everything (posts, pages, tags, cpt, meta)
- WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?
- Order posts by (hierarchical custom) taxonomy terms and term children
- Custom search for custom post type, custom meta and search fields
- Search Post Title Only [duplicate]
- Can’t sort order of wp_query with 2 meta keys
- custom search result page
- Display all Posts and only certain Custom Post Types with meta fields
- Customize Search Results for Custom Post Type
- multiple search forms and search results
- error in Advanced Search Form for Custom Post Types in WordPress array_key_exists() expects parameter 2to be array, string given
- Custom Fields vs Separate Table
- How to search map address in custom post type?
- Issue with pre_get_posts on custom post type archive pages
- How to sort custom post type posts in default order by multiple fields?
- Custom post type show on both Home and Date Archive
- Custom Search for Drafts in Custom Post Type
- pre_get_posts on custom post type
- Search Custom Post Type & Taxonomies
- How to stick custom post at the top in search results
- filter custom post type by meta key in dashboard
- Can I search only some of the fields of a custom post type?
- WordPress sort search results by custom order
- Advanced search form with filters for custom taxonomies
- filter search custom field query
- Include custom taxonomy term in search
- Search one custom post type ONLY, disable “all posts”
- Main menu not appearing in custom post type archive
- Add custom attributes to a post
- Custom Taxonomy Search result page
- Hide custom post type from search based on custom taxonomy
- Pagination on search results page
- Best way to create a search for custom post type by custom field values
- Multi Parameter search with custom post type category and tag
- pre_get_posts works in post type archive but not in single post
- Redirecting search to specific templates with $_GET[“post_type”]
- Search custom type post
- How to Implement Search Functionality?
- How to have multiple search result pages in wordpress with taxonomy terms listed
- Order posts by taxonomy terms
- Query to Exclude Child Pages from Custom Post Type Archive
- How do I troubleshoot pre_get_posts with Debug Bar?
- Creating a custom WP query for a Custom Post Type
- WP_List_Table Inside Metabox Not Working on Clicking Search Button
- Custom Post type doesn’t appear in search results
- search results to show individual ACF fields from inside custom posts
- post_type incorrect for custom post type
- Live search by custom tag
- List all posts associated under custom taxonomy
- how to create custom taxonomy drop downs for parents and child
- CPT year wise archive based on custom date Field
- What’s the most efficient way to get two queries based on an if statement?
- WP_Query with custom post type search showing all results every time
- Extensive search filtering and results->PDF in the front-end
- 404 error Custom search results page for custom post types with friendly URL
- multiple custom post type category selection search
- Custom Search Template for Custom Post Types
- Fetch post meta in the same query as the main loop
- Using $seed on a custom post type for randomly displayed posts
- How do I sort post listing by child post count?
- Multiple search template with separate stylesheets
- Advanced search form with filters for custom taxonomies and custom fields
- Searching for a single custom post type, buddypress
- How do I do this?: If custom post type exists, echo it, else do not
- WordPress search results
- Drop Down Filter with CPT as Options for Search Form
- Searching Custom Posts content with JQuery
- WordPress search results grouped by post type
- Why custom search engine only searches in post titles of custom posts?
- pre_get_posts causes Custom Posts appear under ‘Pages’ menu
- Sorting by Title for Post Archive Categories for Custom Post Type
- Meta_query question
- How can I incldue a “private” post type in a loop for public users?