Page-Of-Posts Template for Twenty Twelve

Page templates are a good way of customising the layout of WordPress sites – and the Codex contains the example code of a ‘Page Of Posts’ page template for the current default theme Twenty Eleven. With the future default theme – Twenty Twelve – of the soon to be released next version of WordPresss already published, there is a need for a new example.

As usual, start by creating a child theme of Twenty Twelve.

The ‘Page Of Posts’ page template is straight forward code:

Please use the code from the pastebin http://pastebin.com/yeGnRkbR

There was some problem with the code below which was unfortunately somehow broken – but seems to be fixed now.

<?php
/**
 * Template Name: Page of Posts
 *
 * for a child theme of Twenty_Twelve
 */

get_header(); ?>

	<div id="primary" class="site-content">
		<div id="content" role="main">

		<?php
			$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
			$args= array(
				'category_name' => 'antiquarianism', // Change this category SLUG to suit your use; or see for query parameters http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
				'paged' => $paged
);
			query_posts($args);
			if( have_posts() ) : ?>

			<?php while ( have_posts() ) : the_post(); ?>
				<?php get_template_part( 'content', get_post_format() ); ?>
				<?php comments_template( '', true ); ?>
			<?php endwhile; // end of the loop. ?>
			
			<?php twentytwelve_content_nav( 'nav-below' ); ?>
			
			<?php else : ?>
			<article id="post-0" class="post no-results not-found">
				<header class="entry-header">
					<h1 class="entry-title"><?php _e( 'Nothing Found', 'twentytwelve' ); ?></h1>
				</header>
				<div class="entry-content">
					<p><?php _e( 'Apologies, but no results were found. Perhaps searching will help find a related post.', 'twentytwelve' ); ?></p>
					<?php get_search_form(); ?>
				</div><!-- .entry-content -->
			</article><!-- #post-0 -->

			<?php endif; wp_reset_query(); ?>

		</div><!-- #content -->
	</div><!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

.