Support » Fixing WordPress » Order posts by ID ?

  • $readposts = get_posts('category=13');
    I am taking posts from category 13.

    How do I order these posts by their ID?

    Many Thanks,

Viewing 5 replies - 1 through 5 (of 5 total)
  • change it to
    $readposts = get_posts(‘category=13&orderby=ID’);

    Thanks for the reply. Still not working for me 🙁
    Here’s my code:

    $readposts = get_posts('category=13&orderby=ID');
        foreach($readposts as $post) : setup_postdata($post);
    				<dt><a href="#"><?php the_title(); ?></a></dt>
    						<li><img src="<?php
    $supporting_image=get_post_meta( $post->ID, 'thumbnail', true );
    if (''!=$supporting_image)
      echo $supporting_image;
    ?>" alt="<?php the_title(); ?>" style="float:left;padding-right:20px;" />
    <?php the_content() ?></li>

    It keeps it in the same order 🙁 Any other ideas?

    sorry about the delay, when you say it keep[s teh same order, by default posts are ordered by id form newest to oldest, how do you want them ordered?

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    If you want oldest first, add order=ASC to that. Like so:

    $readposts = get_posts(‘category=13&orderby=ID&order=ASC’);

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Order posts by ID ?’ is closed to new replies.