Support » Themes and Templates » [Resolved] Change style of stories in category list

[Resolved] Change style of stories in category list

  • Hi,
    I want to change the style of how stories are printed in the category list. Right now, the code is:
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    so all of the posts that are printed have the same style. How can I make the category page for example:
    The first two ‘featured stories’ are printed with a certain style then, the stories below are printed on the page with a different style. This same style would also have to work when you go forward or back pages, listing more stories in the category.

    If you need any more information, just ask.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Howdy Adam,
    Let’s give it a shot, based off your code above.

    if( have_posts() ) {
    $counter = 0;
    while( have_posts() ) {
    // check to see if we are on one of the first 2 items
    if( $counter < 2 ) {
    // do whatever in your theme for the design of your first 2 posts
    } else {
    // do whatever you want for posts after the 2nd one
    } // end while
    } // end if

    Anyway, give that a shot, and let me know if you have questions.
    Take care,

    This works great. Now, I want to skip stories 3,4,5. I am just going to make an extra entry in the if statement to do nothing for these stories. I want them to display with their own style in a sidebar. How do I get stories 3,4,5 on any given page?

    If you need any more information, just let me know.

    Thank you,

    Glad you’re headed in the right direction.

    1. Do you have your blog set up to show “newest 5 posts,” then, in “Settings > Reading?” I’m assuming so, but needed to check.
    2. You want 3,4,5 to show up in a sidebar, in a widget, then?
    — Do they HAVE to be in a widget, or is it okay if they just show up in the sidebar by any means?
    3. What theme are you currently using?

    While you can search on the internet for what you want (mostly) by searching for “access posts from outside the loop,” almost all of these approaches you find are inefficient, requiring a new set of queries.

    If you would please answer my questions above, I’d like to show you how to do this WITHOUT all those extra queries.


    1. Blog pages show at most 10 posts
    Syndication feeds show the most recent 10 items

    2. Widget would be nice.

    3. Currently using Organic News http://organicthemes.com/demo/news/

    Oops, I forgot to ask question number 4:
    What page(s) do you want to do this special situation for?
    Is it a page where you can use a specific Page Template?
    Or, is it on the Home Page?

    This will affect the best approach to the solution.


    It is on the category pages (category.php)

    How would I do this with an additional query?


    Hi again,
    Here is my recommendation:
    1. skip stories 3, 4, 5 in your main loop (you already know how to do that above.)
    2. In your sidebar, include a widget or custom code that does a query for stories 3, 4, and 5.

    Here’s how to do a custom query:

    In your query, you’ll need to use the “offset” parameter so you can get just 3, 4, 5:

    Good luck!

    Thanks! Perfect

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] Change style of stories in category list’ is closed to new replies.