Support » Fixing WordPress » Display posts from single category on blog page template

  • Resolved jmendel

    (@jmendel)


    I need to display posts from a single category (category ID=11) on my theme’s blog template page (page-blog.php). This is the contents of that page:

    <?php
    /*
    Template Name: Blog
    */
    ?>
    <?php get_header(); ?>
    	<div class="content">
    		<h3 class="fancy"><?php _e('Blog','gpp_i18n'); ?></h3>
    		<?php
    		$temp = $wp_query;
    		$wp_query = NULL;
    		$wp_query = new WP_Query();
    		$wp_query->query('&paged='.$paged); $tb_counter = 1;
    		while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    		<div <?php if(function_exists('post_class')) : ?><?php post_class(); ?><?php else : ?>class="post post-<?php the_ID(); ?>"<?php endif; ?>>
    			<h2 class="fancy"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s','gpp_i18n'),the_title_attribute('echo=0')); ?>"><?php the_title(); ?></a></h2>
    			<div class="entry">
    				<?php if ( !post_password_required() ) { ?>
    					<?php include (TEMPLATEPATH . '/apps/multimedia.php'); ?>
    					<?php include (TEMPLATEPATH . '/apps/video.php'); ?>
    				<?php } ?>
    				<?php global $more; $more = 0; the_content(); ?>
    				<?php if ($tb_counter == 1) { ?>
    				<?php include (TEMPLATEPATH . '/apps/ad-main.php'); ?>
    				<?php  } ?>
    			</div><div class="clear"></div>
    		</div><div class="clear"></div>
    		<p class="postmetadata"><?php the_time(__('M d, Y', 'gpp_i18n')); ?> | <?php _e('Categories:','gpp_i18n'); if (the_category(', '))  the_category(); ?> <?php if (get_the_tags()) the_tags(__('| Tags: ','gpp_i18n')); ?> | <?php comments_popup_link(__('Leave A Comment »', 'gpp_i18n'), __('1 Comment »', 'gpp_i18n'),__ngettext('% Comment »', '% Comments »',get_comments_number (),'gpp_i18n')); ?> <?php edit_post_link(__('Edit','gpp_i18n'), '| ', ''); ?></p>
    		<?php $tb_counter++; endwhile; ?>
    		<div class="nav-interior clearfix">
    			<div class="prev"><?php next_posts_link(__('&laquo; Older Entries','gpp_i18n')); ?></div>
    			<div class="next"><?php previous_posts_link(__('Newer Entries &raquo;','gpp_i18n')); ?></div>
    		</div><div class="clear"></div>
    		<?php $wp_query = NULL; $wp_query = $temp;?>
    	</div>
    <?php get_footer(); ?>

    Does anyone know how to accomplish this?

Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Display posts from single category on blog page template’ is closed to new replies.