• I want to sort on the id of the posts. i have tried with this code but it doesn’t work

    <div id=”content” class=”narrowcolumn”>

    <?php $wp_query = new WP_Query(‘orderby=id&order=asc’); ?>

    <?php if (have_posts()) : ?>

Viewing 1 replies (of 1 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    ww.wp.xz.cn Admin

    Are you trying to sort your main posts loop, or are you trying to create a secondary loop for a specific purpose?

    If you want your main Loop to be in ID order, then you just need to add this before that loop:

    <?php query_posts($query_string . "&orderby=ID&order=ASC"); ?>

    But if you’re trying to create a secondary loop for a specific purpose, then you want something more like this:

    <?php
    $wp_query = new WP_Query('orderby=id&order=asc');
    if ($wp_query->have_posts()) : $wp_query->the_post(); ?>

    There are other ways to do these, of course.

Viewing 1 replies (of 1 total)

The topic ‘sort on post id’ is closed to new replies.