Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function noel_recent_projects($atts) {
  2. extract(shortcode_atts(array(
  3. 'count' => 3,
  4. 'thumbs' => true,
  5. 'time' => false
  6. ), $atts));
  7.  
  8. /* generate list from thumbs and links to projects */
  9. $projects = get_posts(array(
  10. 'numberposts' => $count
  11. ));
  12.  
  13. $list = '';
  14. foreach($projects as $item){
  15. $list .= '<li>';
  16. if( (bool) $thumbs && has_post_thumbnail($item->ID) ) {
  17. $list .= get_the_post_thumbnail($item->ID, array(40,40));
  18. }
  19. $list .= '&nbps;&nbps;&nbps;<a href="#/' . esc_attr($item->post_name) . '">' . get_the_title($item->ID) . '</a>&nbps;&nbps;&nbps;';
  20. if( (bool) $time) {
  21. $list .= '<time class="timeago" datetime="' . $item->post_date . '">' . get_the_time('',$item->ID) . '</time>';
  22. }
  23. $list .= '</li>';
  24. }
  25.  
  26. return '<ul class="latest-projects latest-posts">' . $list . '</ul>';
  27. }
  28. add_shortcode('noel_recent_projects', 'noel_recent_projects');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement