WordPress.org

Ready to get started?Download WordPress

Forums

Get posts to show up in reverse order on one category only (8 posts)

  1. mixmastermichael
    Member
    Posted 2 years ago #

    Hi Friends,

    Trying to have it so that there could be a way so that I could get the posts to show in reverse order of what they are now on the page below. I want to have it so that the posts go in reverse order.. most recent post at the top.

    http://pac3carbondale.com/news/

    Anyone know how I could possibly do this? Only trouble is that it differs from the way posts are set up on the home page. Perhaps I could set up a query or something?

    any help would be greatly appreciated

  2. Ryan Yu
    Member
    Posted 2 years ago #

    Hi mixmastermichael,

    You could use query_posts() to reorder your post.
    Check this page out for more details.

    http://codex.wordpress.org/Function_Reference/query_posts

  3. mixmastermichael
    Member
    Posted 2 years ago #

    Thanks for the reply.

    I tried using

    <?php $posts = query_posts( $query_string . '&orderby=title&order=asc' ); ?>

    on the home page posts , and

    <?php

    global $query_string;
    $page = get_query_var('page');
    if (is_category()) query_posts($query_string . "&posts_per_page=$post_number". '&orderby=date&order=desc');
    else query_posts($query_string . "&showposts=$post_number&paged=$page");
    ?>

    for the News category, but it's just not working.

    I've got the ascending order posts to show up for now by using the "Custom Post Order" plugin - but the trouble is that it applies to all sections of the site, including the categories. I need it so that the News category page does not display stuff in Ascending order, but Descending.

    I've re-enabled the custom post order for now. Any ideas?

  4. Ryan Yu
    Member
    Posted 2 years ago #

    What's the php file name for displaying the category like category.php?

    And can you paste the whole code in the category php file?
    Please use pastebin.com

    Will see the code and let you know what we can do.

  5. mixmastermichael
    Member
    Posted 2 years ago #

    thanks for lending a hand.

    Here's the pastebin file for the "blog page" where those posts are coming in.

    http://pastebin.com/HhpXJqiY

    Looking forward to a response.
    Thanks!

  6. Ryan Yu
    Member
    Posted 2 years ago #

    The code you paste is the custom template for Blog page, but I'm not 100% sure if you want to display the category posts within this custom template as well.

    What I understood was you want to display News category in a descending order.
    Is that right?

    Then try this:

    if (is_category('News')) {
    	query_posts('showposts=$et_ptemplate_blog_perpage&cat=news_cat_id&order=DESC');
    }

    and change news_cat_id to the news category id.

    Also it seems you are using Elegant Themes so may need to configure ET settings.

  7. mixmastermichael
    Member
    Posted 2 years ago #

    Okay, thanks so much for the reply. We're getting somewhere.... So I looked within ET settings, and there's a setting to get it so that the posts would appear in Descending order on the categories. The only thing is that there's not a way to do that on the main blog pages, so it would probably have to be done manually I would imagine?

    I put <?php $posts = query_posts( $query_string . '&orderby=title&order=asc' ); ?> in the index.php file, but it didn't seem to do anything. I've reverted to use the Custom Post plugin for now which is how the posts on the site are in reverse order, but will need to get rid of that since it applies to ALL posts on the site including the Category pages.

    This theme is great but confusing... Seems like nothing I try when I add a query like below to the index.php seems to make a difference.
    <?php query_posts($query_string."&orderby=date&order=ASC"); ?>

    I tried adding the code you suggested to the blog.php page, but it didn't seem to do anything. There is no category.php or archives.php file anywhere within the site... weird.

    Any other ideas?? If I could first get the posts on the home page to simply appear in ascending order it would then probably work when I have the ET category settings to DESC.

  8. mixmastermichael
    Member
    Posted 2 years ago #

    bump?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.