Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Page of posts

By: a guest on Dec 30th, 2012  |  syntax: None  |  size: 1.14 KB  |  views: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /*
  3. Template Name: Page of Posts
  4. */
  5.  
  6. /* if you are not using this in a child of Twenty Eleven,
  7. *  you need to replicate the html structure of your own theme.
  8. */
  9.  
  10. get_header(); ?>
  11.  
  12. <div id="primary" class="site-content">
  13.   <div id="content" role="main">
  14.  
  15.   <?php
  16.   /* the_post will retrieve the content of the new page you
  17.   *  create to list the posts, e.g. as an intro to describe
  18.   *  which posts are shown.
  19.   */
  20.   the_post();
  21.  
  22.   // Display content of page
  23.   get_template_part( 'content', get_post_format() );
  24.   wp_reset_postdata();
  25.  
  26.   $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  27.  
  28.   $args = array(
  29.         // Change these category SLUGS to suit your use.
  30.         'category_name' => 'news',
  31.         'paged' => $paged
  32.   );
  33.  
  34.   $list_of_posts = new WP_Query( $args );
  35.  
  36.   twentytwelve_content_nav( 'nav-above' );
  37.   while ( $list_of_posts->have_posts() ): $list_of_posts->the_post();
  38.  
  39.     // Display content of posts
  40.     get_template_part( 'content', get_post_format() );
  41.  
  42.   endwhile;
  43.   twentytwelve_content_nav( 'nav-below' );
  44.   ?>
  45.  
  46.   </div><!-- /#content -->
  47. </div><!-- /#primary -->
  48. <?php get_footer();