Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shortcode to display 'Design' category:
- [loop category=design posts_number="6"]
- -------
- //php code (add into functions.php)
- function myLoop($atts, $content = null) {
- extract(shortcode_atts(array(
- "pagination" => 'true',
- "query" => '',
- "category" => '',
- "posts_number" => '',
- ), $atts));
- global $wp_query,$paged,$post;
- $temp = $wp_query;
- $wp_query= null;
- $wp_query = new WP_Query();
- if(!empty($category)){
- $query .= 'meta_key=post_views_count&orderby=date&category_name='.$category.'&showposts='.$posts_number;
- }
- if(!empty($query)){
- $query .= $query;
- }
- $wp_query->query($query);
- ob_start();
- ?>
- <ul class="loop">
- <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
- <li id="post-<?php the_ID(); ?>" class="threecol item_full body3">
- <?php get_template_part('/includes/post-types/blog-classic'); ?>
- </li>
- <?php endwhile; ?>
- </ul>
- <?php $wp_query = null; $wp_query = $temp;
- $content = ob_get_contents();
- ob_end_clean();
- return $content;
- }
- add_shortcode("loop", "myLoop");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement