Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function category_recent(){
- $cate = get_the_category();
- $current_cat_id = $cate[0]->cat_ID;
- $category = new WP_Query('cat='.$current_cat_id);
- $list = "<ul class='recent-posts'>";
- while($category->have_posts()){
- $category->the_post();
- $upload_dir = wp_upload_dir();
- $post_data = get_post($post->ID, ARRAY_A);
- $slug = $post_data['post_name'];
- ?>
- <li>
- <div class='recentthumb'>
- <a href='<?php the_permalink() ?>' rel='bookmark' title='<?php the_title_attribute(); ?>'>
- <img src='<?php echo esc_url($upload_dir[baseurl])?>/2015/08/<?php echo $slug;?>.jpg' width='196' height='110' alt='<?php the_title_attribute(); ?>' />
- </a>
- <a href='<?php the_permalink() ?>' rel='bookmark' title='<?php the_title_attribute(); ?>'><?php the_title_attribute(); ?></a>
- </div>
- </li>
- <?php
- }
- wp_reset_query();
- return $list . '</ul>';
- }
- add_shortcode('recent-post', 'category_recent');
- <a href="'.$path.'/category_popularity" class="cat_popular">Popular</a>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement