Blog Page Category Template?
-
Currently I’m using Expositio from WPSHOWER and I would like to have a blog page. Sadly the theme doesn’t have this built in and so I figured that I would need to create a new page entitled “News” and apply a page template that would publish posts from a catergory “News”. Sadly I’m not sure how to do this and have followed a tutorial on there and it hasn’t worked.
This is the page template I copied from the tutorial and applied to my blog page….
It displays posts, but it doesn’t display them formatted properly.<?php /* template name: News */ ?> <?php get_header(); ?> <div id="news_post_container"> /* this is the important part: you are creating a query that will post 3 posts from the news category and creating the paging - change any of the parameters that doesn't fit what you want */ <?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query("category_name='news'&showposts=3".'&paged= '.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> /* This is the part that you actually see on the page. I've used the post title meta (which is in my includes folder, and an excerpt */ <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <div id="post"> <h3> <a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3> ? [posted: <?php include (TEMPLATEPATH . '/includes/meta.php' ); ?>] <p><?php the_excerpt(); ?></p> </div> </div> <?php if (($wp_query->current_post + 1) < ($wp_query->post_count)) { echo '<div class="post-item-divider">-----</div>'; } ?> <?php endwhile; ?> /* Here you create the Next/Back links */ <div class="navigation"> <span class="next"><?php next_posts_link('? Older Entries') ?></span> / <span class="back"><?php previous_posts_link('Newer Entries ?')?></span> </div> <?php $wp_query = null; $wp_query = $temp;?> <?php wp_reset_query(); ?> </div> <?php get_footer(); ?>
- The topic ‘Blog Page Category Template?’ is closed to new replies.