Advertisement
Guest User

Page of posts

a guest
Dec 30th, 2012
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  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();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement