• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

How to order search results by date?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to order search results by date?

This topic is: not resolved

Tagged: search results, sort order

  • This topic has 5 replies, 4 voices, and was last updated 9 years, 1 month ago by Victor Font.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • February 23, 2017 at 9:31 am #201820
    webmonkey
    Participant

    In 2013, WordPress introduced a new search sorting mechanism that prioritized results in the following order:

    1. Results with a full sentence match in the post title are listed first.
    2. Results that include all search terms in the title, but not a full sentence match, are listed next.
    3. Results including any search terms in the title, but not all search terms or a full sentence match, are listed next.
    4. Finally, search results that include a full sentence match in the post content come last.
    5. Within each group, results are further sorted chronologically by publication date.

    I want search results to sort by Post/Page date. Are there any code snippets to make this happen by default? I am using Prose, so can add functions without editing the core files.

    February 23, 2017 at 12:34 pm #201834
    Brad Dalton
    Participant

    Try is_search with the pre_get_posts


    Tutorials for StudioPress Themes.

    February 28, 2017 at 3:34 pm #202214
    webmonkey
    Participant

    I'm not sure I want to hack into the WP search.php, although I could stick tweaks in the child theme.

    The weird thing is that WordPress' default is that posts sort by most recent in the tags archives but not, as detailed above, in the search function. I don't understand why there isn't an advanced options section covering things like search.

    February 28, 2017 at 3:58 pm #202215
    Victor Font
    Moderator

    Brad wasn't suggesting that you hack search.php. He was suggesting that you use the pre_get_posts filter to execute a function that passes the orderby to wp_query. You could also use the posts_orderby filter.


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    March 27, 2017 at 1:08 pm #203907
    sminker
    Member

    I need to do this, but I don't understand your instructions about the pre_get_posts_orderby filter. Could you point me in the right direction? I have a limited understanding of PHP.

    March 28, 2017 at 7:39 am #203957
    Victor Font
    Moderator

    https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_orderby


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble