-2

I'm trying to display categories in a list form. Basically, every category (item) in the loop has different style. So I need to display item 1 in one style, item 2, 3, 4 in another style and rest of the items in another style. How do I frame the wordpress for loop structure?

<?php 
if ( have_posts() ) {
    while ( have_posts() ) {
        the_post(); 
        // My Content
    } // end while
} // end if
?>
Shoeb Mirza
  • 912
  • 1
  • 11
  • 30
  • it'd be better to provide your codes and explain the codes instead of providing links to your site – Siavosh Mar 26 '14 at 08:48
  • Well I didn't provide link(s) to my site but only one so that it will be easier to understand my sayings. Category.php link is coming from paste.bin. I'm not expert in PHP so came here to ask help. Thanks – Shoeb Mirza Mar 26 '14 at 08:55
  • because you are showing same category post two times. read code carefully then you can understand – Nanhe Kumar Mar 26 '14 at 08:58
  • in the first question it was a link you edited your question 9 minutes after posting and removed that link I was talking about that link not the pastebin one – Siavosh Mar 26 '14 at 08:59
  • yes dude, I've removed that link upon your saying. You've written I've provided my website "links". But I only posted one link that too deleted after you said. Thanks – Shoeb Mirza Mar 26 '14 at 09:31

1 Answers1

0
<?php $i=1; if (have_posts()): while ( have_posts() ) : the_post();
if($i==1){ ?> 
... code for the first post ... 
<?php } if(($i>1)&&($i<5)) { ?>
... code for 2nd, 3rd, 4th post ...
<?php } if($i>4) { ?>
... code for 5th, 6th, 7th, 8th post ...
<?php } $i++; endwhile; endif; ?>

^ This is to display posts with different styles

AndrePliz
  • 259
  • 1
  • 2
  • 11
  • Thanks but I really don't know how to change my category.php with the above code. Could you please edit my category.php and give me? – Shoeb Mirza Mar 26 '14 at 09:43