The param name is s not search
.
So your query ignores the search
param and returns all cpts.
And your $_GET
input should be sanitized before use.
's' => sanitize_text_field( $_GET['q'] ),
Related Posts:
- AJAX search on post pages by custom post type
- How to make a WP_Query search with custom post types?
- Development of a WordPress Search Plugin – Best Practices
- Search multiple custom fields by using meta_query
- WordPress post sorting with AJAX
- Search Custom Post Type with all meta attached?
- How Do I Use WP_Query to Run This Database Query as Search Result?
- Search tags in CPTs
- Including Custom Meta with posts_where query
- Filtering WP_Query Dynamically on the Front-End
- Why get_posts() not returning only selected category posts from Custom Post Type?
- Storing posts from query and accessing later via AJAX call
- WP_Query inside foreach loop returning same value for all options when filtered using ajax
- Including metaboxes from custom post types in global search — continued
- Pagination with custom query, custom search form, single and pages, ajax and no plugins
- Advanced search form with filters for custom taxonomies
- Retrieve custom post types by custom taxonomies with WP_Query
- Custom filter for main search: how to exclude specific post_type from search results
- how to get this tax_query working?
- find custom post type post by searching its custom field with my string
- Searching post types
- Display custom-post type based on the Title matching the current selected value
- Change search query in wordpress custom post type
- Search for custom field input of a custom post type in ajax live search
- Filtering posts based on three taxonomies
- Search Function not searching correct custom_post_type even though post_type is defined in search args
- post_type incorrect for custom post type
- Live search by custom tag
- Ajax load more inside custom post type taxonomy
- Create Second Search Page Only for Custom Post Type
- Conditional posts in WP_query for search
- Manually build WP_Query
- WP_Query with custom post type search showing all results every time
- How to load more custom type posts through AJAX & LOAD MORE POSTS button
- Custom post type blog pagination conflict
- Customising wordpress search and using $_GET[“s”]
- Why does ‘exclude_from_search’ exclude a custom post type from WP_Query?
- Searching Custom Posts content with JQuery
- Custom post archive with search, is_search() is false?
- Load posts via AJAX without draft status
- How to use a custom post type archive as front page?
- Combining queries with different arguments per post type
- The Operator “NOT IN” Does Not Work In tax_query
- Returning search results by relevance, including Custom Post Types
- How to replicate some of Drupal Views functionality in WordPress?
- Exclude from search all custom posts which are NOT in a taxonomy term
- How to get_queried_object on multiple objects?
- How to get the parent’s taxonomy?
- New WP_query in template not working with CPT+category on some pages
- Displaying a specific post in a wp query by post id
- Query current and future events, ordered by begin date
- Search Custom Post Type Custom Fields
- Optimised Code for Pulling Taxonomy Posts
- How can I get the first 50% of all posts (within a custom post type)?
- Remove duplicated values from a loop
- is there a way to retrieve posts that do not have a featured image assigned?
- Why does querying on post_tags (which has been applied to custom post types) only return posts?
- shortcode to show custom post types by category
- Loading custom content type from ajax results?
- convert custom query to wp_query
- Search Custom Post Type & Taxonomies
- Loop to fetch 3 post_thumbnail instances from 3 most recent custom post types named “portfolio”
- filter custom post type by meta key in dashboard
- How to use load more custom post type data normal or according to on click category tab In WP
- filter search custom field query
- $post not working working in AJAX plugin with custom post type
- Using wp_query to modify the loop in index.php for a CPT
- Custom Taxonomy Search result page
- How to sort a WP_Query by a custom field AND ALSO filter by a different custom field
- Undefined $post in wp_query
- Get current user id
- WP Query results showing posts outside of category ID
- List latest post out of 2 custom post types
- How to count other posts not having specific taxonomy terms?
- How to properly use Categories with Custom Post Types
- Displaying Portfolio Filter by Category Order (alphabetically)
- Custom Post Type Query W/Category Dropdown
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- Pin posts to top of custom loop
- WP Admin Dropdown List Filter for custom (ACF) field on custom post type(s)
- WP_Query – How To Query Only Custom Posts With No Children of Their Own?
- Query custom post type and custom field by URL parameters
- Custom Taxonomy – fields
- CPT Loop, include taxonomies and disclude others?
- Custom Post Type Query by user id
- CPT post doesnt shows tags and category on backend admin page
- Adding a nav menu for a custom post type
- How to use costum database table for custom post type
- Most efficient way of showing children posts?
- Querying, storing, and using data from 2 separate custom post types
- date_query won’t accept day parameter, but will accept month and year for a custom post
- Custom post type and custom taxonomies display
- Custom Post ‘Post Per Page’ Crashing Page?
- 404 error Custom search results page for custom post types with friendly URL
- Issue with permalinks for custom post type
- Paged within a custom content type template [duplicate]
- WordPress can only query up to 766
- How to exclude certain portfolios from a loop
- show the most recent date of all posts to display on front end
- WP Query – Can’t get posts with specific taxonomy