I recently had a similar problem and it had something to do with the query’s posts_per_page
parameter. Try setting it explicitly, like so:
function custom_search_filter($query) {
if ( !is_admin() && $query->is_main_query() ) {
if ($query->is_search) {
$query->set('posts_per_page', 10 ); // Try setting it to the number you've set in the WordPress admin (Settings > Reading).
$query->set('post_type', array('post','product'));
}
}
}
add_action('pre_get_posts','custom_search_filter');
Hope this helps!
Related Posts:
- Exclude a term of a taxonomy with a custom post type in a search
- Set meta_query only for specific post type
- Blank search results on custom search
- Custom Search Template for Custom Post Types
- Woocommerce search pagination not working
- WooCommerce Customer Role Delete Custom Post Type
- Including metaboxes from custom post types in global search — continued
- Custom post type not showing in search result
- WooCommerce sort products by the actual product width(not the shipping width)
- Manage custom post type in woocommerce /my-account/ page
- Woocommerce custom field search in custom post type [closed]
- What to and how to proceed with CPT to make DB small and efficient?
- Pretty URL for custom search for custom post type
- Add post location with mile radius allowing search
- Include custom post type content in search
- Modifying custom post type created by WooCommerce
- Get post count for search result based on post type
- Hide a widget inside a div on specific type of post
- Auto Complete Search
- Allow add new post access to custom post but not wp post for some role
- search suggest – filter post type
- Searching Custom Post Types
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- Display Woocommerce Orders for specific author [closed]
- How do i search authors from search form using author’s name
- Remotely search WordPress sites using xml-rpc
- BBPress Search results in WordPress search
- Limit Search to Post Type With Apostrophe return search not found
- Search filter triggered & sort by custom post type
- Set Custom Post Type in Widget Settings for use in Widget
- Displaying and searching Custom Posts
- Search by tag name and category
- Searching Custom Fields
- Advanced search form with filters for custom taxonomies
- dropdowboxes with pre-selected custom fields optios that filters the results according seach needs
- filter search custom field query
- Different results between permalink and query var search
- How to let users choose where to search for posts?
- WordPress Custom Search by post_type
- Include custom taxonomy term in search
- What content types are shown at a search page?
- Can NOT search my custom post type?
- Sort posts in loop by the WooCommerce Membership of the author
- Search one custom post type ONLY, disable “all posts”
- Custom post_type search pages
- Pagination Error : Duplicate argument being outputted
- WordPress search and date filter not working with custom post type
- Custom Empty Results page for my Custom Post Type
- How to set up Custom Post Type archive page as Front page
- Custom filter for main search: how to exclude specific post_type from search results
- Add custom attributes to a post
- Display an icon based on post type
- how to get this tax_query working?
- Select2 AJAX and WP Query Returns ALL and does not filter
- Custom Taxonomy Search result page
- How to group search results by post type and only if post type result is not empty?
- find custom post type post by searching its custom field with my string
- search custom post type by custom fields on front end
- Prevent A Specific Custom Post Type Showing In WP Search Results Page
- Category Search / Custom Post Type search on my website. Custom Post Types that are “page-like”?
- Copy order items with metadata between orders – Woocommerce
- Custom Search | check multiple meta_value for search value
- Hide custom post type from search based on custom taxonomy
- Update Post Status On Woocommerce Payment Complete
- Get all post from a post type
- What is the correct term for a tool that filters content based on metadata?
- Pagination on search results page
- Custom Post Type to replace Woocommerce products – page not found error
- CPT as Product in WooCommerce
- Ideas on how to organize a project [closed]
- Change permalink for custom_post_type using custom_post_meta (woocommerce)
- Best way to create a search for custom post type by custom field values
- Filtering custom posts by custom fields (ACF) [closed]
- Searching post types
- Multi Parameter search with custom post type category and tag
- CPT, meta-data, url parameter
- Get Terms from Custom Taxonomy and Current Post
- Limit search field to just search a custom post type with custom fields
- Search CPT Title AND Meta
- Building a Data Intensive Website with WordPress
- Display future posts in search
- Redirecting search to specific templates with $_GET[“post_type”]
- Modifying search results based on post_type
- Is it a connection or relationship between 2 custom post types?
- Search custom type post
- How to Implement Search Functionality?
- How to have multiple search result pages in wordpress with taxonomy terms listed
- WordPress CPT Taxonomy Dashboard Search – How to include taxonomy in search?
- Is it possible to get the specific content on the search page?
- Change search query in wordpress custom post type
- Custom Post type to Woocommerce Product type
- How to display related posts using the same taxonomy for custom types (WordPress, Pods, Woo)
- Search for custom field input of a custom post type in ajax live search
- How to display custom field in product description?
- Create a post automatically if search result has zero results
- Add two custom product type
- Duplicate the “Orders” list on Admin Page
- What’s the best way to do this: inquiry/ticket system?
- Sudden 404 pages on product category archives
- WordPress shortcode to pull product post data