Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2018
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. function communityjunction_recent_blog_posts_1($atts, $content = null) {
  2. extract(shortcode_atts(array(
  3. "number_of_posts" => '4'
  4. ), $atts));
  5.  
  6. ob_start();
  7. ?>
  8.  
  9. <div class="shortcode-recent-blog-posts-1">
  10.  
  11. <ul id="latest-posts">
  12. <?php
  13. $temp = $wp_query;
  14. $wp_query = new WP_Query();
  15. $wp_query->query('posts_per_page=' . $number_of_posts . ''.'&paged='.$paged);
  16. while ($wp_query->have_posts()) : $wp_query->the_post();
  17. ?>
  18.  
  19. <li class="blog-thumbs-view-entry">
  20. <div class="blog-thumb">
  21.  
  22. <?php if ( has_post_thumbnail() ) { ?>
  23. <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('post-thumbnail'); ?></a>
  24. <?php } else { ?>
  25. <a href="<?php the_permalink(); ?>"><img src="<?php echo plugin_dir_url( __FILE__ ) ?>/images/no-thumbnail.png"></a>
  26. <?php } ?>
  27.  
  28. <div class="blog-box-comments">
  29. <span><?php comments_number('0', '1', '%'); ?></span>
  30. <div class="clear"></div>
  31. <div class="blog-box-comments-buble"></div>
  32. </div>
  33. </div>
  34. <div class="blog-box-bottom">
  35. <div class="blog-thumb-title"><a href="<?php the_permalink(); ?>"><?php $thetitle = get_the_title(); $getlength = strlen($thetitle); $thelength = 57; echo mb_substr($thetitle, 0, $thelength, 'UTF-8'); if ($getlength > $thelength) echo "..."; ?></a></div>
  36. </div>
  37.  
  38. <div class="blog-box-details">
  39. <?php the_category(', ') ?>, <span class="blog-box-time"><?php printf( _x( '%s ago', '%s = human-readable time difference', 'your-text-domain' ), human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) ); ?></span>
  40. </div>
  41.  
  42. </li>
  43.  
  44. <?php
  45. endwhile;
  46. wp_reset_query();
  47. ?>
  48. </ul>
  49.  
  50. <?php $wp_query = null; $wp_query = $temp; ?>
  51.  
  52. </div> <!-- tabs-container2 -->
  53.  
  54. <?php
  55. $shortcode_content = ob_get_clean();
  56. return $shortcode_content;
  57.  
  58. }
  59. add_shortcode("communityjunction-recent-blog-posts-1", "communityjunction_recent_blog_posts_1");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement