Page of Posts: How to show posts in a specific category
-
Hello
Ive followed the directions in your codex of how to create a page of posts, but the posts from the category will not show up. is there a way that I can show posts from a specific category, and its sub-categories? Here is the code that I created for the posts
<?php if (is_page() ) { $category = get_post_meta($posts[0]->ID, 'category', true); } if ($category) { $cat = get_cat_ID($category); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $post_per_page = 4; // -1 shows all posts $do_not_show_stickies = 1; // 0 to show stickies $args=array( 'category__in' => array($cat), 'orderby' => 'date', 'order' => 'DESC', 'paged' => $paged, 'posts_per_page' => $post_per_page, 'caller_get_posts' => $do_not_show_stickies ); $temp = $wp_query; // assign orginal query to temp variable for later use $wp_query = null; $wp_query = new WP_Query($args); if( have_posts() ) : while ($wp_query->have_posts("cat=1")) : $wp_query->the_post("cat=1"); ?> <span class="style1"><strong><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php $short_title = the_title('','',false); $short_title = substr($short_title,0,44); echo $short_title; if($short_title_2!=$short_title) { echo "..."; }?></a></strong><br /></span> <span class="style1"><?php the_excerpt(); ?></span> <span class="style1">▪ <?php the_time('d M, Y','',''); ?> ▪ <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?><br /><br /></span> <?php endwhile; ?> <?php else : ?> <?php endif; $wp_query = $temp; //reset back to original query } // if ($category) ?>
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Page of Posts: How to show posts in a specific category’ is closed to new replies.