• Resolved mcgeorge312

    (@mcgeorge312)


    I want to write my blog like a book… I want the posts to appear with the oldest one first and the newest one last. I’ve checked the dashboard and am having no luck. I know it must be simple, but I don’t understand PHP.

    Can anyone help me with this? I’d really appreciate it.

    Here is my template code:

    <?php get_header(); ?>

    <div id=”main”>

    <div id=”contentwrapper”>

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>

    <div class=”topPost”>
    <h2 class=”topTitle”>“><?php the_title(); ?></h2>
    <p class=”topMeta”>by <?php the_author_posts_link(); ?> on <?php the_time(‘M.d, Y’) ?>, under <?php the_category(‘, ‘); ?></p>
    <div class=”topContent”><?php the_content(‘(continue reading…)’); ?></div>
    <span class=”topComments”><?php comments_popup_link(‘Leave a Comment’, ‘1 Comment’, ‘% Comments’); ?></span>
    <span class=”topTags”><?php the_tags(‘:‘, ‘, ‘, ”); ?></span>
    <span class=”topMore”>“>more…</span>
    <div class=”cleared”></div>
    </div> <!– Closes topPost –>

    <?php endwhile; ?>

    <?php else : ?>

    <div class=”topPost”>
    <h2 class=”topTitle”>“>Not Found</h2>
    <div class=”topContent”><p>Sorry, but you are looking for something that isn’t here. You can search again by using this form…</p></div>
    </div> <!– Closes topPost –>

    <?php endif; ?>

    <div id=”nextprevious”>
    <div class=”alignleft”><?php posts_nav_link(”,”,’« PREVIOUS ENTRIES’) ?></div>
    <div class=”alignright”><?php posts_nav_link(”,’NEXT ENTRIES »’,”) ?></div>
    <div class=”cleared”></div>
    </div>
    </div> <!– Closes contentwrapper–>

Viewing 12 replies - 1 through 12 (of 12 total)
  • Change this

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

    to

    <?php
    query_posts($query_string . '&order=ASC');
    if (have_posts()) : ?>

    Or consider a plugin such as Query Posts Reloaded.

    Thread Starter mcgeorge312

    (@mcgeorge312)

    Thank you so much for the quick response! I really appreciate it. I did exactly what you said and I got this error:

    Parse error: parse error, unexpected $ in /home/content/c/a/r/carlynelson/html/wp-content/themes/pixeled/index.php on line 54

    Thread Starter mcgeorge312

    (@mcgeorge312)

    <div id=”contentwrapper”>

    <!—- <?php if (have_posts()) : ?> ——–>

    <?php
    query_posts($query_string . ‘&order=ASC’);
    if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>

    I did exactly what you said

    Not true, please review.

    If necessary, paste your complete template at wordpress.pastebin.ca and report the link back here.

    Thread Starter mcgeorge312

    (@mcgeorge312)

    I don’t get it. I copied and pasted your code right from this page. I did review it and I don’t see the difference. I’ll try again and see what happens.

    Thread Starter mcgeorge312

    (@mcgeorge312)

    I pasted the code here. Thanks!

    https://wordpress.pastebin.ca/1435269

    You can’t just cut and paste the code provided because you haven’t defined $query_string. Try this:

    <?php query_posts('showposts=5&order=ASC'); ?>
    <?php while (have_posts()) : the_post(); ?>

    You can control the number of posts shown using ‘showposts’.

    The fact of $query_string being defined (or not) would not cause an error per se, and I believe $query_string is the right thing to use there.

    The problem is mcgeorge312 DID NOT follow the directions. The result was an invalid comment string around a statement.

    Please delete this line:

    <!—- <?php if (have_posts()) : ?> ——–>

    I would like to do the same thing as well which template is being edited to do this?

    Ok i was able to achieve this in the categories template but could it be done in the main index template

    Same code will work in an index.php, at least it works with the WordPress Default theme’s index.php

    Thread Starter mcgeorge312

    (@mcgeorge312)

    Thanks!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Display posts in Ascending order?’ is closed to new replies.