Support » Theme: Quark » Posts Ascending Order

  • Resolved mbadawi23

    (@mbadawi23)


    Hello again,

    I have a quick question. I’m trying to show my posts in ascending order so older posts are shown first on my posts page. I found comments online to add query_posts($query_string . "&order=ASC"); before the posts loop. So where is the posts loop located?

    Thanks a lot.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Theme Author Anthony Hortin

    (@ahortin)

    The correct way to change your query is using pre_get_posts. To reverse the order the blog posts are displayed, you can add this to your functions.php file.

    function my_pre_get_posts( $query ) {
       global $wp;
       if ( !is_admin() && is_home() && $query->is_main_query() ) {
          $query->set( 'order', 'ASC' );
          return;
       }
    }
    add_action( 'pre_get_posts', 'my_pre_get_posts' );

    Thanks a lot.. that worked as a charm.

    Theme Author Anthony Hortin

    (@ahortin)

    You’re welcome. Glad it solved your problem.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Posts Ascending Order’ is closed to new replies.