Advertisement
Guest User

Untitled

a guest
Aug 31st, 2015
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. function category_recent(){
  2. $cate = get_the_category();
  3. $current_cat_id = $cate[0]->cat_ID;
  4. $category = new WP_Query('cat='.$current_cat_id);
  5.  
  6. $list = "<ul class='recent-posts'>";
  7. while($category->have_posts()){
  8. $category->the_post();
  9. $upload_dir = wp_upload_dir();
  10.  
  11. $post_data = get_post($post->ID, ARRAY_A);
  12. $slug = $post_data['post_name'];
  13. ?>
  14. <li>
  15. <div class='recentthumb'>
  16. <a href='<?php the_permalink() ?>' rel='bookmark' title='<?php the_title_attribute(); ?>'>
  17. <img src='<?php echo esc_url($upload_dir[baseurl])?>/2015/08/<?php echo $slug;?>.jpg' width='196' height='110' alt='<?php the_title_attribute(); ?>' />
  18. </a>
  19. <a href='<?php the_permalink() ?>' rel='bookmark' title='<?php the_title_attribute(); ?>'><?php the_title_attribute(); ?></a>
  20. </div>
  21. </li>
  22. <?php
  23. }
  24. wp_reset_query();
  25. return $list . '</ul>';
  26. }
  27. add_shortcode('recent-post', 'category_recent');
  28.  
  29. <a href="'.$path.'/category_popularity" class="cat_popular">Popular</a>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement