ThemeShaper Forums » Thematic

[closed]

How do I show OLDEST posts first?

(7 posts)
  • Started 4 years ago by WaltKania
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. WaltKania
    Member

    For my purposes, it makes a more sense to show my posts in the order they were created, NOT the latest first. Is there a way to tweak .php to show the posts in REVERSE chronological order? Meaning, the most recent posts LAST? I poked around the .php files but couldn't find what governed the date order of the posts.

    Any advice?

    I'm using Thematic, a child theme now. Will soon be using Thematic Feature Site.

    Posted 4 years ago #
  2. Hi,

    try this code in your child theme's functions.php:

    function blue_monday() {
    	query_posts($query_string . "&order=ASC");
    }
    add_action('thematic_above_indexloop', 'blue_monday');

    Chris

    Posted 4 years ago #
  3. How can this be modified to allow for different orders in different categories? Can it?

    Posted 4 years ago #
  4. Hi,

    this would be something like:

    function blue_monday() {
        if (is_category('Whatever') {
    	query_posts($query_string . "&order=ASC");
        } elseif (is_category('Something else') {
            query_posts($query_string - "&order=DESC");
        }
    }
    add_action('thematic_above_categoryloop', 'blue_monday');

    Chris

    Posted 4 years ago #
  5. Thanks Chris,

    I want to use the postMash Filtered plugin to be able to manually order posts in one category (1) and for that to work I need to specify &orderby=menu_order&order=ASC but for all other categories I would want it sorted by date, DESC.

    Here is the code I'm using to achieve this:

    function orderPosts($orderBy) {
    	global $wpdb;
    	if(is_category('1')) {
    		$orderBy = "{$wpdb->posts}.menu_order ASC";
    	} else {
    		$orderBy = "{$wpdb->posts}.date DESC";
    	}
    	return($orderBy);
    }
    add_filter('posts_orderby', 'orderPosts');

    That totally messes up my home page display and the display of other pages and categories too. What am I doing wrong?

    Posted 4 years ago #
  6. iCristiano
    Member

    I have a curious problem with that!

    I used this action to change de order of the posts:

    function blue_monday() {
    	query_posts($query_string . "&order=ASC");
    }
    add_action('thematic_above_indexloop', 'blue_monday');

    The result: I get the oldest post first, but just one. Then, the order keeps the same it was before, I mean, the newest post first.

    I mean, I have 4 posts. Normaly, they are ordered like that:

    nov 13 - post 1
    nov 10 - post 2
    nov 07 - post 3
    oct 05 - post 4

    when I use the action, this is what happens:

    oct 05 - post 4
    nov 13 - post 1
    nov 10 - post 2
    nov 07 - post 3

    Curious, no? Any idea?
    Thanks!

    Posted 2 years ago #
  7. i always like to use wp_parse_args for adjusting the query params (that way i don't lose the tricky $paged variable. how about trying:

    function oldestfirst() {
      global $wp_query;
      $defaults = $wp_query->query_vars;
      $new = array('order'=> 'ASC');
      $args = wp_parse_args( $new, $defaults );
      query_posts($args);
    }
    add_action('thematic_above_indexloop','oldestfirst');
    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.