WordPress.org

Ready to get started?Download WordPress

Forums

Posts are displaying alphabetically instead of by date (4 posts)

  1. zarastudios
    Member
    Posted 9 years ago #

    Hi. I have the following on my index page to show the most recent posts from two categories. However, instead of ordering the posts by date, it orders them alphabetically. I've tried a few things and can't seem to get the problem fixed. Thanks in advance for your help.


    <p class="greentitle">News</p>
    <p />
    <?php query_posts('cat=1&showposts=1'); ?>
    <?php while(have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <div class="post-info"><h2 class="post-title"><a href="<?php

    the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php

    the_title(); ?>"><?php the_title(); ?></a></h2>
    </div>
    <div class="post-content">
    <?php the_content(); ?>
    <div class="post-info">
    <p class="post-date">Posted on <?php the_time('D j M Y'); ?> <?php

    edit_post_link('(edit this)'); ?></p>
    <?php wp_link_pages(); ?>
    </div>
    <!--
    <?php trackback_rdf(); ?>
    -->
    </div>
    <?php comments_template(); // Get wp-comments.php template ?>
    </div>
    <?php endwhile; ?>
    <p class="greentitle">Articles</p>
    <p />
    <?php query_posts('cat=4&showposts=2'); ?>
    <?php while(have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <div class="post-info"><h2 class="post-title"><a href="<?php

    the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php

    the_title(); ?>"><?php the_title(); ?></a></h2>
    </div>
    <div class="post-content">
    <?php the_content(); ?>
    <div class="post-info">
    <p class="post-date">Posted on <?php the_time('D j M Y'); ?> <?php

    edit_post_link('(edit this)'); ?></p>
    <?php wp_link_pages(); ?>
    </div>
    <!--
    <?php trackback_rdf(); ?>
    -->
    </div>
    <?php comments_template(); // Get wp-comments.php template ?>
    </div>
    <?php endwhile; ?>

  2. Joshua Sigar
    Member
    Posted 9 years ago #

  3. zarastudios
    Member
    Posted 9 years ago #

    Thanks, but I've already tried that. I want the posts to display by date, not alphabetically. They should display by date, but they aren't and I don't know why. One of the things I tried was modifying the code like this

    <?php query_posts('cat=1&showposts=1&orderby=date&order=des'); ?>

    but that didn't work either.

  4. Joshua Sigar
    Member
    Posted 9 years ago #

    Sorry, I misread your post the first time. You just want one most recent post from category 1, right.

    <?php
    query_posts('cat=1&showposts=1');
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.