I am using short codes in theme for grid display. Code only considers category ids. I also want to add custom taxonomies so it give output as both category posts as well as custom taxonomy posts.
function five_col( $atts ) {
extract( shortcode_atts( array(
'cats' => '1',
'num' => '2',
'offset' => '0',
), $atts ) );
$sq = new WP_Query(array('posts_per_page' => $num, 'post_status' => 'publish', 'order' => 'desc', 'ignore_sticky_posts' => 1, 'cat' => $cats, 'offset' => $offset));
if ($sq->have_posts()) :
$count = 1;
$col = 5;
$out = '<ul class="three_col">';
while ($sq->have_posts()) : $sq->the_post();
$thumbClass = ($count == $col) ? 'last' : '';
$permalink = get_permalink();
$title = get_the_title();
$bloginfo = get_template_directory_uri();
if ( has_post_thumbnail()) {
$img_src = wp_get_attachment_image_src( get_post_thumbnail_id($GLOBALS['post']->ID), '');
$thumbnail = $img_src[0];
}
else $thumbnail = '';
$default_thumb = $bloginfo.'/images/post_thumb.jpg';
$thumbnail = ( $thumbnail == '' ) ? $default_thumb : $thumbnail;
$format = '<li class="'.$thumbClass.'"><a href="%3$s" title="%4$s"><div class="img_thumb"><img src="%1$s/scripts/timthumb.php?src=%2$s&w=70&h=130&zc=1&q=100" alt="%4$s"/></div><h5><a href="%3$s" rel="bookmark" title="' . __( 'Permanent Link to %4$s', 'volt' ) . '">%4$s</a></h5></li></a>';
$out .= sprintf ($format, $bloginfo, $thumbnail, $permalink, $title );
$count++;
if($count > $col){
$col = $col + 5;
$out .= '<li class="clear"></li>';
}
endwhile;
$out .= '</ul>';
return $out;
endif;
wp_reset_postdata(); // Restore global post data stomped by the_post().
}