Don’t create a new WP_Query. As per the template hierarchy WordPress uses the search.php template in your theme for the search results page. This template just needs to contain The Loop, and the only posts inside that will be your search results.
See Twenty Seventeen’s search results template as an example: https://github.com/WordPress/twentyseventeen/blob/master/search.php
Related Posts:
- Query multiple custom post types in single loop
- How to create a WP_Query to search the Title or Tag?
- Display related products with custom output
- How to get to a specific position in wp_query?
- Why is variable not working on custom sql query using wpdb?
- Create WP_Query to search for posts by their categories or their parent/child categories
- WP Query with custom Shortcode
- unable to use ‘new WP_Query’ in AJAX call
- How to add div blocks after certain set of post
- How to overwrite orderby with add_query_var
- How to display SQL query that ran in WC_Order_Query?
- How to hide posts of a specific custom category in WordPress?
- How can I modify this code to make the search box include tags and meta
- wordpress query returning unexpected results
- Query doesn’t display text data with apostrophes
- How can I display a query in a page?
- Does wp_query and query_posts affect website performance? [duplicate]
- Show post like this image in my newssite [closed]
- Three different queries on same page
- How do I use WP_query with multiple post IDs?
- Include WP_Query in my own PHP file?
- Inject post (from specific category) between posts in Loop
- is_page() not working from within a plugin
- Passing JSON data from WP Query into AJAX causing NULL errors
- How to order posts by modified date without using ‘query_posts’?
- Result of Custom WP_Query appears on 404 Page (but result are found!)
- Show only one post for each author ( Page loads too slow )
- Specific Loop For 2 Within Each
- How to add 2 posts under another post? Formatting should be intact
- what is diference wp_get_attachment_url / wp_get_attachment_src / get_post_thumbnail_id?
- Modern Tribe Calendar wp-query with meta query not working at all
- WP database error for comments_popup_link()
- Count number of published posts by type
- How to display custom field on homepage
- Can an array be used as a meta_query value?
- Can’t increase posts_per_page by variable
- WordPress WP_Query() Not working properly
- Get taxonomy terms only of the WP_Query current posts
- List User order by ID in Descending order (Backend)
- How to do multiple searches (with logical OR) in WP_Query in hook pre_get_posts?
- Random order of WP_Query results with highest meta value
- get current custom post ID by WP_Query method
- How to securely provide a $_POST var in WP_Query with PHP 7?
- If Query In Sidebar
- ACF: how do I get the fields and its values of a specific group?
- Set WP_query ‘order’ option by another tables value
- creat filter with wp_query
- WordPress default Search function inconsistent in WooCommerce Product Titles
- WordPress SQL injection
- Which is the correct way to conditionally enqueue a CSS file?
- Security for data obtained from the database
- How to get all author posts outside of author templates
- How to get post ID in a Page?
- How to retrieve the data from the sever and displaying it in a page?
- How to list commenters and days since last commented
- Can’t update multiple rows with $wpdb query
- How to override url params with rewrite rules vars?
- Store metakey value as an array
- Custom Post type slider with thumbnail navigation
- Post not populating for custom post type based on category selection
- Infinite Loop – WP_Query
- Limit tags shown in post
- Why my query does not run with prepare
- List of Events with Multiple Dates: Only NEXT Date
- WordPress SQL JOIN query
- WP_Query and help with the loop for magazine front page
- Wp Query : Order by distance lat,lon
- How to WP_Query posts order by parent title?
- search.php to search only the post title
- WP_Query – How to query all of post types categories
- How to work Woocommerce pagination inside shortcode?
- WordPress Custom Form – Getting Query Vars, Weird Glitch?
- Using a new WP_Query inside the loop
- wp_Query with mutuplea values returns all posts
- Display articles with a different template in the home page | Solved |
- Category Page Displaying all Pages
- Use WPQuery to match to specific repeater row in post
- WP_QUERY post_in problem
- how to get data from two different table from wordpress database
- Assign meta_query value to php variable
- WordPress search query, how to modify the sql
- Modify post image in full size
- How to display sticky post always at the top (before regular post) in wordpress?
- Making list of posts with chosen description
- Ordering / grouping posts by datepicker ACF
- Include search tags and users in my search results system
- Add custom taxonomy to custom search for posts
- My query keeps looping infinitely ! how to stop it?
- How to add thumbnails from recent posts to owl-carousel in wordpress automatically?
- direct query to post_meta table
- Only Get A Certain Number of Posts From WP_Query
- Querying posts based off a jquery datepicker
- “Where… like” query not working as expected
- Use custom get results query to show posts WordPress
- List sibling pages widget, exclude current page
- Problems With Query and/or Template Part and/or PHP
- How to callback custom field text
- WP Query conflict on tag.php and category.php template
- How to sort custom sortable column by custom table value
- /page/2/ redirect to 404