Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function myLoop($atts, $content = null) {
- extract(shortcode_atts(array(
- "pagination" => 'true',
- "query" => '',
- "category" => '',
- ), $atts));
- global $wp_query,$paged,$post;
- $temp = $wp_query;
- $today = getdate();
- $wp_query = new WP_Query( 'year=' . $today["year"] . '&monthnum=' . $today["mon"] . '&day=' . $today["mday"] );
- if($pagination == 'true'){
- $query .= '&paged='.$paged;
- }
- if(!empty($category)){
- $query .= '&category_name='.$category;
- }
- if(!empty($query)){
- $query .= $query;
- }
- ob_start();
- ?>
- <h2><?php echo $category; ?></h2>
- <ul class="loop">
- <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
- <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php echo $thumbnail_image; the_title(); ?></a></li>
- <?php endwhile; ?>
- </ul>
- <?php if(pagination == 'true'){ ?>
- <div class="navigation">
- <div class="alignleft"><?php previous_posts_link('« Previous') ?></div>
- <div class="alignright"><?php next_posts_link('More »') ?></div>
- </div>
- <?php } ?>
- <?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