WordPress.org

Support

Support » Plugins and Hacks » Control which posts appear inside categories?

Control which posts appear inside categories?

  • boldlygo
    Member

    @boldlygo

    I have some well-written posts that I would like to appear in the results first when someone clicks on a category. Is there a way to assign a few posts to appear first in a category, and then have the rest of the posts appear in order of date?

    thanks,

Viewing 3 replies - 1 through 3 (of 3 total)
  • nicktank
    Member

    @nicktank

    There is a way, you would have to do a little work in your theme to add a function to the loop to look for a set group of posts with certain categories first and then fill in the rest.

    (For the important posts. Category #5 is set for top priority)

    <?php query_posts('&cat=5); ?> <!-- Edit the cat= part to the number of the desired category (check the category IDs in your WordPress system), and this will show the 1st of the chosen category -->
    				<?php while (have_posts()) : the_post(); ?>

    (Then let the rest of the posts come in. Make sure the category in this string is set to -5 to prevent duplication)

    <?php query_posts('&cat=-5'); ?> <!-- Edit the cat= part to the number of the desired category (check the category IDs in your WordPress system), and this will show the 1st of the chosen category -->
    				<?php while (have_posts()) : the_post(); ?>
    boldlygo
    Member

    @boldlygo

    Hmm…

    The way my site is setup now I have category/pages at the top of the screen. When someone clicks on a category they see all the posts in that category.

    Could I create a category within a category? So someone clicks on category “science” and it displays “top-science” before displaying the rest of the science posts?

    thanks,

    nicktank
    Member

    @nicktank

    I’ll look into this. I’m on deadline for a project right now but as soon as I get some breathing room I’ll give this a shot. I’m curious about it as well.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Control which posts appear inside categories?’ is closed to new replies.