WordPress.org

Ready to get started?Download WordPress

Forums

Chronological Category Page W/O "More" Dividers (9 posts)

  1. ABetterUsername
    Member
    Posted 8 years ago #

    This is two seperate questions. I'd like for a given category page to display posts in order, rather than in reverse order. I'd also like to somehow disable the "more" dividers on that one page.

    Is this possible?

  2. ABetterUsername
    Member
    Posted 8 years ago #

    AM bump. I hope that's kosher.

  3. moshu
    Member
    Posted 8 years ago #

    Yes, they are 2 different questions and need different approach.

    1. Use a custom Category Template and modify the Loop to get the desired order:
    http://codex.wordpress.org/The_Loop
    http://codex.wordpress.org/Template_Tags/query_posts
    http://codex.wordpress.org/Category_Templates

    2. If you included the "more" tag when writing your post - the setting is stored in the DB and will take effect even in the Category Template.
    What I'd do: use the_excerpt tag in the index and the_content on the Cat. Template (no need for "more" in this case; look up the two template tags in the Codex).

  4. tsguitar
    Member
    Posted 8 years ago #

    A bump is never kosher, AM or otherwise.

    This will help you identify a specific category page:
    if (is_category('Foo') && !is_single())

    At the top of your category template, you should have this:
    <?php if (have_posts()) : ?>

    Just before that line, paste this:

    <?php if (is_category('Foo') && !is_single())
    {
    query_posts(order=ASC)
    } ?>

    That *should* tell WP that, if this page is a Foo archive page, display the posts in ascending order instead of descending order. Give it a try, then post back.

  5. ABetterUsername
    Member
    Posted 8 years ago #

    Thank you! I feel bad that there was something in the documentation and I missed it.

    About the code to stick in the category template, I got "Parse error: syntax error, unexpected '=' in (long url) category-2.php on line 4"

    Doesn't like the =ASC.

  6. tsguitar
    Member
    Posted 8 years ago #

    Maybe 'order=ASC' instead (note the single quotation marks around it).

    Here's more info:
    http://codex.wordpress.org/Template_Tags/query_posts

  7. ABetterUsername
    Member
    Posted 8 years ago #

    I got "unexpected } on line 5." I wanted to at least do *something* before I came whining back to you, so I just removed it. That netted me "unexpected $end on line 54." But there's no $end, expected or otherwise.

    I found a plugin that orders posts chronologically in all archives, but that's kind of inelegant.

  8. tsguitar
    Member
    Posted 8 years ago #

    Try this:
    <?php if (is_category('Foo') && !is_single())
    {
    query_posts('category_name=Foo&order=ASC')
    } ?>

    And this is all going just before the beginning of your Loop, right before:
    <?php if (have_posts()) : ?>

    Can you post all the whole code? Not in this thread; use pastebin or something.

  9. ABetterUsername
    Member
    Posted 8 years ago #

    Thanks for the reply. I cannot believe how patient you're being with me. I saw you're a reader of McLuhan and thought I'd mention I'm a reader of Neal Postman. :)

    Okay, so for reasons I cannot explain, if I scrap all the standard Category Template code except the Loop and change the {}s in your code to ()s, I don't get an error message. Of course, the whole thing is so crazy looking I can't tell if it's your code working there or not, but the posts do appear in ascending order. Not really a solution, so I scrapped that in favor of making the template work.

    This is the code I've currently got up. It's the Category Template from the wordpress wiki with your code in it. I'm getting "error on line 6" when I try to make use of it. If I change the {}s to ()s in your code or even remove it altogether, I get an error message somewhere around line 54 informing me of an unexpected $end.

    http://pastebin.ca/133150

Topic Closed

This topic has been closed to new replies.

About this Topic