iam working on my first wp theme and iam new to php and wordpress. i need to create a single category widget that displays at least five posts from specific category. inside this post loop i need a conditional function to make the first post different from the rest. to be clear iam using a plugin that gives me all the needed option except conditional function that makes the first post different from the others. is there any one could help me By editing the plugin file to add this conditional function . or showing me the entire code from scratch.thanks

2 Answers 2


To make the first post different you could add a post counter and change the output on the first loop.

$counter = 0
while ( $cat_posts->have_posts() ) {

 if ( $counter == 0 ) {

 // Out put the different loop


  //Normal loop output
  • thanx Chris that's exactly what I meant .i tested it and works for me Commented Oct 30, 2011 at 21:15

There isn't much code to this plugin, main output is done by pretty straightforward loop.

Unfortunately plugin gives no way to control styling of individual items so you will have to either:

  • fork it and edit to output class for styling for first item alone

  • try to make use of CSS for styling of existing markup (:first-child if I am not mistaken)

  • thanks Rarst . but i wanted it in the loop because iam going to display just the thumb in the first post.. Commented Oct 30, 2011 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.