I have the following shortcode added to my functions.php. Source: http://www.wprecipes.com/wordpress-shortcode-display-the-loop
function myLoop($atts, $content = null) {
extract(shortcode_atts(array(
"pagination" => 'true',
"query" => '',
"category" => ''
), $atts));
global $wp_query,$paged,$post;
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
if($pagination == 'true'){
$query .= '&paged='.$paged;
}
if(!empty($category)){
$query .= '&category_name='.$category;
}
if(!empty($query)){
$query .= $query;
}
$wp_query->query($query);
ob_start();
?>
<?php
if ( get_query_var( 'paged') ) { $paged = get_query_var( 'paged' ); } elseif ( get_query_var( 'page') ) { $paged = get_query_var( 'page' ); } else { $paged = 1; }
$query_args = apply_filters( 'woo_blog_template_query_args', $query_args ); // Do not remove. Used to exclude categories from displaying here.
if ( have_posts() ) {
$count = 0;
while ( have_posts() ) { the_post(); $count++;
?>
<!-- Post Starts -->
<div <?php post_class('drop-shadow lifted'); ?>>
<h2 class="title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<?php woo_post_meta(); ?>
<div class="entry">
<?php if ( $woo_options['woo_post_content'] != 'content' ) { woo_image( 'width=' . $woo_options['woo_thumb_w'] . '&height='.$woo_options['woo_thumb_h'] . '&class=thumbnail ' . $woo_options['woo_thumb_align'] ); } ?>
<?php global $more; $more = 0; ?>
<?php if ( $woo_options['woo_post_content'] == 'content' ) { the_content(__( 'Read More...', 'woothemes' ) ); } else { the_excerpt(); } ?>
</div>
<div class="fix"></div>
<div class="post-more">
<span class="comments"><?php comments_popup_link( __( 'Leave a comment', 'woothemes' ), __( '1 Comment', 'woothemes' ), __( '% Comments', 'woothemes' ) ); ?></span>
<?php if ( $woo_options['woo_post_content'] == 'excerpt' ) { ?>
<span class="post-more-sep">•</span>
<span class="read-more"><a href="<?php the_permalink(); ?>" title="<?php esc_attr_e( 'Continue Reading →', 'woothemes' ); ?>"><?php _e( 'Continue Reading →', 'woothemes' ); ?></a></span>
<?php } ?>
</div>
</div><!-- /.post -->
<?php
} // End WHILE Loop
} else {
?>
<div <?php post_class(); ?>>
<p><?php _e( 'Sorry, no posts matched your criteria.', 'woothemes' ); ?></p>
</div><!-- /.post -->
<?php } // End IF Statement ?>
<?php if($pagination == 'true'){ ?>
<?php woo_pagenav(); ?>
<?php } ?>
<?php $wp_query = null; $wp_query = $temp;
$content = ob_get_contents();
ob_end_clean();
return $content;
}
add_shortcode("loop", "myLoop");
See my working example here: http://174.122.31.60/test/things-to-do/attractions-shopping-etc/. Can someone tell me how to add additional attributes such as “order”, “posts_per_page”, etc.?
Many Thanks,
Travis