Show all categories and posts in sidebar



//get all categories then display all posts in each term


$taxonomy = ‘category’;


$param_type = ‘category__in’;




‘orderby’ => ‘name’,


‘order’ => ‘ASC’




$terms = get_terms($taxonomy,$term_args);


if ($terms) {


foreach( $terms as $term ) {




“$param_type” => array($term->term_id),


‘post_type’ => ‘post’,


‘post_status’ => ‘publish’,


‘posts_per_page’ => -1,


‘caller_get_posts’=> 1




$my_query = null;


$my_query = new WP_Query($args);


if( $my_query->have_posts() ) {  ?>




<h3><?php echo ‘Category ‘.$term->name;?></h3>






while ($my_query->have_posts()) : $my_query->the_post(); ?>


<li><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></a></li>




















wp_reset_query();  // Restore global post data stomped by the_post().



This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s