Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function communityjunction_recent_blog_posts_1($atts, $content = null) {
- extract(shortcode_atts(array(
- "number_of_posts" => '4'
- ), $atts));
- ob_start();
- ?>
- <div class="shortcode-recent-blog-posts-1">
- <ul id="latest-posts">
- <?php
- $temp = $wp_query;
- $wp_query = new WP_Query();
- $wp_query->query('posts_per_page=' . $number_of_posts . ''.'&paged='.$paged);
- while ($wp_query->have_posts()) : $wp_query->the_post();
- ?>
- <li class="blog-thumbs-view-entry">
- <div class="blog-thumb">
- <?php if ( has_post_thumbnail() ) { ?>
- <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('post-thumbnail'); ?></a>
- <?php } else { ?>
- <a href="<?php the_permalink(); ?>"><img src="<?php echo plugin_dir_url( __FILE__ ) ?>/images/no-thumbnail.png"></a>
- <?php } ?>
- <div class="blog-box-comments">
- <span><?php comments_number('0', '1', '%'); ?></span>
- <div class="clear"></div>
- <div class="blog-box-comments-buble"></div>
- </div>
- </div>
- <div class="blog-box-bottom">
- <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>
- </div>
- <div class="blog-box-details">
- <?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>
- </div>
- </li>
- <?php
- endwhile;
- wp_reset_query();
- ?>
- </ul>
- <?php $wp_query = null; $wp_query = $temp; ?>
- </div> <!-- tabs-container2 -->
- <?php
- $shortcode_content = ob_get_clean();
- return $shortcode_content;
- }
- add_shortcode("communityjunction-recent-blog-posts-1", "communityjunction_recent_blog_posts_1");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement