Advertisement
alchymyth

no empty div

Aug 6th, 2011
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. <?php
  2. $count = 0;
  3. $result = '';
  4. $catposts = get_posts('cat=8&&numberposts=0');
  5. if ( $catposts ) { //if there are any posts
  6. foreach($catposts as $single):
  7. setup_postdata($single);
  8. $mylimit=1 * 7200; //days * seconds per day
  9. $post_age = date('U') - mysql2date('U', $single->post_date_gmt);
  10. if ($post_age < $mylimit) {
  11. $count++;
  12. if ( $count < 4 ) { // only process 3
  13.  
  14. $result .= '<a href=';
  15. $result .=get_permalink($single->ID).'>'.$single->post_title.'</a>';
  16. }
  17. }
  18. endforeach;
  19. if ($result ==''){}
  20. else{ ?>
  21. <div id="whatshot">
  22. <?php
  23. echo "<h2><a href='/category/hot/'>The Latest</a></h2><ul>";
  24. echo $result."</ul>"; ?>
  25. </div>
  26. <?php
  27. }
  28. }
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement