Posted By

gera3d on 07/15/10


Tagged

wordpress loop


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

osirisinternet


Featured Post on Wordpress


 / Published in: PHP
 

This code goes into the index.php

  1. <?php while (have_posts()) : the_post(); ?>
  2. <!-- EVEN IF YOU'VE GOT PAGEST OF POSTS AFTER THE HOMEPAGE, ONLY THE FIRST POST ON THE FIRST PAGE WILL BE STYLED DIFFERENTLY -->
  3. <?php if (is_paged()) : ?>
  4. <?php $postclass = ('regular'); ?>
  5. <?php else : ?>
  6. <?php $postclass = ($post == $posts[0]) ? 'featured' : 'regular'; ?>
  7. <?php endif; ?>
  8.  
  9. <!-- NOW THAT WE'VE SET UP THE CONDITIONS, LETS CREATE A DIV WITH THE CSS CLASS FED DYNAMICALLY -->
  10. <div class="<?php echo $postclass; ?>">
  11. <!-- THIS IS WHERE ALL THE SCRIPT FOR YOUR POST GOES -->
  12.  
  13. <?php comments_template() ?>
  14. <?php endwhile ?>

Report this snippet  

You need to login to post a comment.