• Good morning,

    Reference website: https://www.psschina.com

    I have a few boxes on the front page of my company website, which is set up to display posts from a specific category. The problem is, I would like the ability to reorder the posts (I think it defaults to chronological order, with the newest at the top).

    Currently, we have the latest blog post in the #1 position, but I would like to move that to #4. Posts 1, 2, and 3 are permanent information links, so I think they should be the most prominent. Is there a code or a plugin that will allow me to change the way posts are organized within a category? I know there are many that let you rearrange categories, but not the items within each category.

    Thank you for your help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You can add a query post string to your index.php to change the order of posts as described here Template Tags/query posts ? WordPress Codex so the most recent post is at the #4 spot (assuming the permanent posts #1 to #3 will always have older publication dates.

    Or you set your reading maximum to 3 posts and put a new query in your template to show the one lastest post in that category, with excerpt parameters and styling to make it look the same as the other posts:

    <?php $my_query = new WP_Query('category_name=mycategory&showposts=1'); ?><?php while ($my_query->have_posts()) : $my_query->the_post(); ?><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a><?php the_excerpt();?><?php endwhile; ?>

    Thread Starter andao

    (@andao)

    Reverse chronological order would be perfect, could you send the code for that? Which php should I edit? Index? Thank you.

    I work in a theme called Thesis and I wanted to do the same thing. I got advice on their forum to put this code into something in thesis called a custom_functions.php file but that’s within the theme so I don’t know where you’d put it if you had a different theme.

    function reorder_posts() {
    if (is_category()) {
    global $query;
        query_posts($query . 'order=ASC');
        }
    }
    add_action('thesis_hook_before_content','reorder_posts');

    BUT the reason I’m over on this forum is because when I use that code, EVERY post comes up on every category list, even if it’s not actually in that category.

    The site is https://mysticscribbles.com/ if anyone wants to see what happens – that links to a category page where only the very last post is supposed to display. YIKES! Any help would be greatly appreciated!!!

    Thank you in advance,
    Sandee

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Want a category to sort posts differently’ is closed to new replies.