Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $contributions = get_posts(array(
- 'posts_per_page' => 5,
- 'ignore_sticky_posts' => 1,
- 'post_type' => 'contributions',
- ));
- $widget_markup = <<<EOT
- <div class="contribution-widget widget-closed widget widget-container" id="contributorwidget">
- <h3><a href="/contributions/">Contributors!</a></h3>
- <div class="textwidget">
- <ul class="posts">
- EOT;
- if(!empty($contributions)) {
- foreach($contributions as $contribution) {
- $contrib_title = get_the_title($contribution->ID);
- $contrib_url = get_permalink($contribution);
- $widget_markup .= '<li class="clearfix">';
- if(has_post_thumbnail($contribution->ID)){
- $thumb_url = wp_get_attachment_image_src( get_post_thumbnail_id($contribution->ID), 'thumbnail' );
- $thumb_img = '<img width="' . $thumb_url[1] . '" height="' . $thumb_url[2] . '" data-original="' . esc_url($thumb_url[0]) . '" src="' . PLACE_IMAGE . '" />';
- $widget_markup .= '<a title="' . $contrib_title . '" href="' . $contrib_url . '">' . $thumb_img . '</a>';
- }
- // Link to article:
- $widget_markup .= '<a class="title" rel="bookmark" title="'. $contrib_title .'" href="' . $contrib_url . '">'. $contrib_title .'</a> ';
- // Author byline
- $widget_markup .= '<span class="byline">by <a class="byline" rel="author" href="' . get_author_posts_url($contribution->post_author) . '">';
- $widget_markup .= get_the_author_meta('display_name', $contribution->post_author);
- $widget_markup .= '</a></span> ';
- // Comments count link:
- if($contribution->comment_count >= 100) {
- $widget_markup .= '<a class="hot-story" href="'. $contrib_url .'#comments">' . $contribution->comment_count . ' Comments</a>';
- }
- else {
- $widget_markup .= '<a href="'. $contrib_url .'">Read More</a>';
- }
- $widget_markup .= '</li>';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement