• 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

Reverse Post Order

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 › General Discussion › Reverse Post Order

This topic is: not resolved
  • This topic has 5 replies, 2 voices, and was last updated 7 years, 7 months ago by defree99.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • August 7, 2015 at 9:06 am #161700
    defree99
    Participant

    I'm using Enterprise theme here: http://doityourselfpestandweedcontrol.com/category/news-articles/

    I imported a bunch of posts (all in one category) but after importing they now display in reverse order.

    So I need to simply need to reverse the order of the Posts.

    I'd rather not use a plugin if possible.

    Is there a way to do this?

    August 7, 2015 at 12:45 pm #161738
    Chuck
    Member

    Hey,
    Try these functions listed here:
    https://surefirewebservices.com/how-to-reverse-the-post-order-using-the-genesis-framework/

    Looks they should work for you.


    Chuck Smith
    Twitter: @polishedwp

    August 7, 2015 at 12:58 pm #161740
    defree99
    Participant

    Thanks for finding this.

    I put the following into my Functions file but it not work:

    //* Reverse Post Order
    add_action(‘genesis_before_loop’, ‘child_before_loop’);
    function child_before_loop () {
    global $query_string;
    query_posts($query_string . "&order=ASC");

    }

    Can you see what I did wrong?

    August 7, 2015 at 8:59 pm #161772
    Chuck
    Member

    Okay I figured it out... I could not get that function to work either. I found this:

    Rewrote the function to check for either front-page, archive page, or archive post. I tested here on a clean sub-domain with Genesis Sample installed. Look at the front-page and the blog page an notice the date order of the posts.

    http://sample.polishedwp.com/

    Chuck Smith
    Polishedwp.com


    Chuck Smith
    Twitter: @polishedwp

    August 8, 2015 at 4:03 pm #161798
    Chuck
    Member

    Function was stripped:

    add_action( 'pre_get_posts', 'prefix_reverse_post_order' );
    
    function prefix_reverse_post_order( $query ) {
    	if ( is_admin() )
    		return;
    	
    	// Only change the query for post archives.
    	if ( $query->is_main_query() || is_front_page() || is_archive() || is_post_type_archive() ) {
    		$query->set( 'orderby', 'date' );
    		$query->set( 'order', 'ASC' );
    	}
    }

    Chuck Smith
    Twitter: @polishedwp

    August 12, 2015 at 2:56 pm #162198
    defree99
    Participant

    Thanks!

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘General Discussion’ 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

© 2023 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