Advertisement
alchymyth

empty div with get_posts

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