WordPress.org

Forums

sort category posts by date asc (4 posts)

  1. staceppa
    Member
    Posted 6 years ago #

    hi
    i am trying to show the posts of a certain categoy (ID:306) ordered by date ascending (instead that descending) but it seems that i am not succeding in it.
    Can anyone please tell me exactly what to modify and where?
    Thanks

  2. MichaelH
    Member
    Posted 6 years ago #

    You can create a category template (in your case it would be category-306.php) with a query_posts() loop.

    <?php
    query_posts($query_string.'&order=ASC');
    if (have_posts()) :
    while (have_posts()) : the_post();
    <!-- display post e.g. the_content() -->
    endwhile;
    endif;
    ?>

    Resources:
    The Loop
    Template Hierarchy

  3. rbernabe
    Member
    Posted 6 years ago #

    I've been trying this every which way, and it's not working properly for me:

    <?php query_posts($query_string.'&orderby=date&order=ASC'); ?>
        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                    <div id="post-<?php the_ID(); ?>" class="thumbnail">
    <a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><h3 id="post-<?php t
    he_ID(); ?>"><?php the_title(); ?></h3><img src="<?php echo get_post_meta($post->ID, "Thumbnail", true);
    ?>" alt="<?php the_title(); ?> <?php _e(''); ?>" /></a>
          <p><?php the_category(', ') ?></p>
    </div>
    
        <?php endwhile; //end one post ?>
    <?php endif; ?>

    The results are still ordered by title alphabetically. Can you help?

  4. trestianub
    Member
    Posted 5 years ago #

    Hy there

    i'm interested in that aswell and i got an ideea but i'm a designer not a programer http://logitune.fm i want to order the events so that i can show the next events on the homepage

    so what about ordering by date if i make the date a custom field... am i talking non sense or is that posible?

    can anyone help?

    tnx
    Bogdan

Topic Closed

This topic has been closed to new replies.

About this Topic