WordPress.org

Ready to get started?Download WordPress

Forums

Control which posts appear inside categories? (4 posts)

  1. boldlygo
    Member
    Posted 5 years ago #

    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,

  2. nicktank
    Member
    Posted 5 years ago #

    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(); ?>
  3. boldlygo
    Member
    Posted 5 years ago #

    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,

  4. nicktank
    Member
    Posted 5 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic