The loop doesn not display the latest posts, it just shows the posts the main query has found. On your search page the main query returns search results, and you can change its order (we have plenty of examples for that on our site).
WordPress looks for the parameter s
or /search/
in the request URI and decides to do a search query then. That’s what you see as results. You don’t have to do anything more, if you are happy with those results. It happens automatically.
Related Posts:
- A search for ‘0’ returns results
- If No Search Results, Show Posts from Alternate Search Query
- Custom search form to display users only
- How to get an array of years from all of the search results, and use it to filter by year the paginated loop?
- How to go about combining dropdowns / filter queries?
- Get search.php results in header.php?
- Filter the_posts doesn’t work on search page
- How to modify search.php to not show pages only show posts
- Include future posts in tags and in search
- Search page loop banner image issue
- How do I set the Stewart Search Template to return only published posts in the result
- Trying to get all links in my posts
- Work arounds for conditional checks inside the loop in search.php?
- Search – Check if post is a page on search page
- Eliminate duplicates in a foreach loop [closed]
- Multiple Loops Homepage?
- Why is it necessary to call rewind_posts() when using the loop more than once? [duplicate]
- Is including the loop necessary for page.php? [duplicate]
- Identify the page being shown while in The Loop
- How to find meta_values to call
- Alternate loop output every three posts (within the same original loop)
- Group search results by post type, but hide post types with no results
- Previous and Next Post link doesn’t work
- Random post, page inside post loop problem
- In a foreach loop, how do I target the last item in the loop?
- Users instead of posts: How to modify the main query?
- single page site with subpages
- Different Queries Return Same Results [closed]
- wordpress simple loop, huge issues
- Pagination gives extra page with no results
- Better way to display posts from specific categories, in a grid layout
- Infinite Redirect Loop after moving to subdirectory
- Loop after page content
- WordPress Loop – Not returning projects in specific category
- Next and Previous loop
- WordPress Search Results for Multiple Post Types
- add most viewed post by google analytic in loop [closed]
- Query reset problem or flawed code to enable custom post type query
- Sort posts by most recently modified
- Exclude posts from main loop based on meta value
- Using an ACF field from a page within a post loop?
- trouble calling an import class from an action in a plugin before wp_cron executes
- Blog page Server error 500 with stick post loop in query.php
- How to fix pagination for custom loops?
- Show all posts using the template page and the loop?
- ‘Auto Draft’ Post showing in wordpress loop
- How do I display an image before the first post of the loop when I’m using get_template_part?
- Why does `inclusive` not work in this wordpress loop?
- How do I automate multiple category loops?
- Multiple get_posts() queries on one page
- Custom loop not working
- Loop inside query
- In Custom page – next_posts_link Not working while previous_posts_link is working
- Escape current post from loop
- Why isn’t my multiple loops working?
- How can I display other user avatars on an author profile page?
- something strange is happening to my code
- facebook like, tweet and google+1 buttons inside the loop on home, archive and search pages and missing facebook like buttons
- Loop Offset for tag based “Related Posts”
- How do I put my frontpage featured image in a page template for home.php?
- Randomly display post based on meta value. (Kind of Priority/Weight)
- How to print redux gallery feilds id? [closed]
- Why the first with flexslider appears as blank on my code?
- Rendering pages
- How can have a conditional template tag based on the main loop within a secondary loop with new WP_Query(), using get_template_part()
- WP_Query is only looping home page, not pages
- How to filter posts by category INSIDE the loop
- static page with multiple loops breaks post pagination
- new custom theme – posts displaying on top of one another
- Getting selection of posts based on loop variables via Ajax
- Why would this code work locally but break online?
- Why would a completely normal loop give offset errors and maximum execution time errors?
- Avoid WP_Query’s duplicate posts with taxonomies
- How can I change how my tag pages display?
- Properly loop through and paginate page on each function call
- Get a Post Loop based on Logged in User information into a Shortcode
- Loop keeps showing the same post even when I click on a different one
- Display all the terms within a custom taxonomy
- Submit form for loop of products of the term with AJAX
- Last post in loop when even
- Customizer settings using “for” loop
- Repeat code, change variable?
- Foreach loop inside foreach loop?
- Ajax category pagination problem
- Unable to login + Redirect loop on mobile
- Variable not working in sidebar loop
- Combine Query and Select Database to create directory loop
- My custom query not detecting the correct category
- 2 loops in blog homepage
- In Loop Output Place Custom Field Content In Between Paragraphs
- wordpress showing all posts instead of date range
- Help with add_filter(‘the_content’, ‘some_function’) and multiple matches
- Single Loop With Dual Content Area
- ACF loops false value with repeater and checkbox
- How to do query_posts on tags pages
- the_content() “crashes” for single pages
- How to toggle a div element between two images when click two submit buttons in a wordpress loop?
- Best hook for a function which adds shortcodes to the system?
- Same posts within a paginated page
- Adding vkontakte social “like” button to posts results in multiple buttons on first post only