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
- Search and filter terms of a custom post type only and display results
- How do I update_post_meta() or add_post_meta() with an AJAX call
- How to query Posts from a custom post type which contains a custom taxonomy?
- Best way to create a search for custom post type by custom field values
- Creating a Tabbed Widget
- Create query for both custom post type and category
- Filtering custom posts by custom fields (ACF) [closed]
- Post ordering not working with custom field
- Custom Post Type Archive Pagination
- Query Posts that have Custom Taxonomy
- Display post from custom post type
- Custom Plugin – Query CPT – Display Results
- List all Custom Post Type posts excluding certain Taxnomy term
- Running a custom query inside another cpt single and trying to grab a variable
- Get posts by category name
- Query Posts, order by meta value
- Multiple wp_editor instances in custom post type using Ajax
- WP_Meta_Query object with conditionals
- WP_Query: Posts within category OR custom post type
- foreach loop inside the loop creating duplicates in output
- Blank search results on custom search
- Multi Parameter search with custom post type category and tag
- list posts of two post types in a single template
- Sorting by meta_key different to search criteria?
- CPT, meta-data, url parameter
- Shortcode / WP_Query in post changes context
- Using WP meta query to show custom post types by a start and finish date
- Two queries – one with checkbox ticked, one without – comparing meta_query
- Foreach loop returning more than one item when querying taxonomy
- Limit search field to just search a custom post type with custom fields
- How to properly use Categories with Custom Post Types
- Getting titles from an array of IDs
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- wp_query not returning my custom post
- Problem while filtering by ‘category_name’
- All blog posts are not showing up
- Search CPT Title AND Meta
- How to fetch posts that are stored in the different table than (default) wp_posts?
- WP_Query of a custom post type isn’t working
- WP_Query order custom post type with certain meta key value by post modified date
- Change Post Meta via AJAX from the posts list table
- Cant’ Display Custom Post Type Title Base on Tax Terms
- wp_dropdown_pages with tax_query clause
- Cache issue with WP_Query and custom field filtering
- Post Type => Any conundrum
- Query custom posts from custom taxonomy
- filter the_content, custom post type, and wp_query
- Building a Data Intensive Website with WordPress
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- Displaying Portfolio Filter by Category Order (alphabetically)
- Make Next and Previous on single-$posttype.php use the same order as archive-$posttype.php
- Query Custom Post Type by Taxonomy
- Custom post-type custom query – show all posts
- Display featured posts for a custom post type by taxonomy
- Display future posts in search
- Redirecting search to specific templates with $_GET[“post_type”]
- How to filter a static post page with ajax and $wp_query
- Get_the_term_list inexplicably adds values in foreach
- Single parent post lists child posts with pagination
- How do I list a custom field and custom taxonomies for each result in a loop?