Created
March 7, 2012 05:07
-
-
Save krogsgard/1991039 to your computer and use it in GitHub Desktop.
query_posts in page template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $args = array( | |
'post_type' => array ( 'post', 'page' ), | |
'posts_per_page' => 1, | |
'paged' => ( get_query_var('page') ? get_query_var('page') : 1 ) | |
); ?> | |
<?php query_posts( $args ); ?> | |
<?php if ( have_posts() ) : ?> | |
<?php while ( have_posts() ) : the_post(); ?> | |
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> | |
<header class="entry-header"> | |
<h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h1> | |
</header><!-- .entry-header --> | |
<div class="entry-content"> | |
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyeleven' ) ); ?> | |
<?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'twentyeleven' ) . '</span>', 'after' => '</div>' ) ); ?> | |
</div><!-- .entry-content --> | |
</article><!-- #post-<?php the_ID(); ?> --> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
<div class="navigation"> | |
<div class="alignleft"><?php previous_posts_link('« Previous') ?></div> | |
<div class="alignright"><?php next_posts_link('More »') ?></div> | |
</div> | |
<?php wp_reset_query(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment