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
- If Query In Sidebar
- Recent Posts slider, using WP_Query(), loads duplicate sliders
- mysql query from wordpress page using custom table
- Compare post-IDs within WP_Query? (Less than / Greater than)
- WordPress 3.2 query_posts and pagination, permalinks issue
- only show container with next/prev links if they exist?
- What query string parameter is available for index.php, that works for both pages and blog articles?
- ACF: how do I get the fields and its values of a specific group?
- How to use $query->set with post__in?
- Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?
- Loading the same WP_Query in two different wordpress .php templates
- How to prevent WP_Query function from returning all posts when empty?
- Dynamic content based on a URL parameter
- Set WP_query ‘order’ option by another tables value
- Display a specific category of products in shop page and disable code for specific actions
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- creat filter with wp_query
- WordPress default Search function inconsistent in WooCommerce Product Titles
- Add more button if more 8 items
- How to store post ID’s in cookie or session to display the same posts later
- WordPress, AJAX and pre_get_posts using conditional tags
- Increase offset while looping
- Get users that likes the post
- Long running queries
- wpdb php get_var query to get ID for URL image doesn’t work for ID over 999
- get_posts() and WP_query limits ‘AND’ conditions to a maximum of 6 for meta value queries in WordPress
- Exclude posts based on meta value
- How to pre populate a form field with a link of a current user’s author profile?
- Two queries for a WP_User_Query search work perfectly apart, but not together
- Trying to get a PHP variable defined in a custom post into a javascript file. Null value. Using wp_localize_script
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Custom query, checking values of multiple meta keys
- auto-populating custom nav with all items from custom post type
- inserting a post from an extern php file but post content doesn’t show on wp site
- Query if audio attachment AND/OR custom field
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- Remove echo from shortcode
- How Can I use WP_Query to Only Display 1 Post from Custom Post Type if Query Returns Posts with Matching ID in Custom Field
- register_taxonomy() take much queries
- WordPress theme options error
- WordPress SQL injection
- Which is the correct way to conditionally enqueue a CSS file?
- Security for data obtained from the database
- Fatal error: Call to a member function query() on a non-object
- Get posts from multiple post type
- Odd / Even posts add class minus first post
- Is it possible to retrieve all posts with a certain value for metadata?
- How to get all author posts outside of author templates
- WP_Query fails despite having 1 post
- Create a Blog Template Page
- wp_query get the 2nd post
- Exclude posts with specific metadata from search?
- How to get post ID in a Page?
- Parse error: syntax error, unexpected ‘}’ on get_the_author_meta [closed]
- Display an image if odd number of posts in grid
- 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
- working with term_relationships table
- Why doesn’t PhotoSmash plugin play well with wp_query?
- get_the_ID() in the footer returns wrong value
- Trouble inputting variable into WP query
- the_posts_pagination() not working in wpquery
- WordPress query undefined offset in loop
- How to override url params with rewrite rules vars?
- Can I make get_users() query global?
- WP_Query: getting posts where custom field exists
- How to show meta value code HTML after x paragraph
- Form search query – displaying ACF “Post Object” field as results
- WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank
- Convert a string into a decimal number for use in query
- Issue with custom loop in Archive page
- get_the_ID() doesnt work
- Array to string conversion on array_map
- Store metakey value as an array
- Increment paged on WP_Query
- Target post_date_gmt if it’s empty or not set
- Custom Post type slider with thumbnail navigation
- Hide posts if user is added to it WP_query
- Parse error: syntax error, unexpected ‘}’ [closed]
- Custom route and query