Guest User

Untitled

a guest
Sep 15th, 2015
92
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $contributions = get_posts(array(
  2. 'posts_per_page' => 5,
  3. 'ignore_sticky_posts' => 1,
  4. 'post_type' => 'contributions',
  5. ));
  6.  
  7. $widget_markup = <<<EOT
  8. <div class="contribution-widget widget-closed widget widget-container" id="contributorwidget">
  9. <h3><a href="/contributions/">Contributors!</a></h3>
  10. <div class="textwidget">
  11. <ul class="posts">
  12. EOT;
  13. if(!empty($contributions)) {
  14. foreach($contributions as $contribution) {
  15.  
  16. $contrib_title = get_the_title($contribution->ID);
  17. $contrib_url = get_permalink($contribution);
  18.  
  19. $widget_markup .= '<li class="clearfix">';
  20.  
  21. if(has_post_thumbnail($contribution->ID)){
  22. $thumb_url = wp_get_attachment_image_src( get_post_thumbnail_id($contribution->ID), 'thumbnail' );
  23. $thumb_img = '<img width="' . $thumb_url[1] . '" height="' . $thumb_url[2] . '" data-original="' . esc_url($thumb_url[0]) . '" src="' . PLACE_IMAGE . '" />';
  24. $widget_markup .= '<a title="' . $contrib_title . '" href="' . $contrib_url . '">' . $thumb_img . '</a>';
  25. }
  26.  
  27. // Link to article:
  28. $widget_markup .= '<a class="title" rel="bookmark" title="'. $contrib_title .'" href="' . $contrib_url . '">'. $contrib_title .'</a> ';
  29.  
  30. // Author byline
  31. $widget_markup .= '<span class="byline">by <a class="byline" rel="author" href="' . get_author_posts_url($contribution->post_author) . '">';
  32. $widget_markup .= get_the_author_meta('display_name', $contribution->post_author);
  33. $widget_markup .= '</a></span> ';
  34.  
  35. // Comments count link:
  36. if($contribution->comment_count >= 100) {
  37. $widget_markup .= '<a class="hot-story" href="'. $contrib_url .'#comments">' . $contribution->comment_count . ' Comments</a>';
  38. }
  39. else {
  40. $widget_markup .= '<a href="'. $contrib_url .'">Read More</a>';
  41.  
  42. }
  43. $widget_markup .= '</li>';
  44. }
  45. }
RAW Paste Data