Advertisement
cosmocanuck

Blog Template with pagination

Jun 2nd, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. <?php
  2. /**
  3. * Template Name: Blog
  4. */
  5. get_header(); ?>
  6.  
  7. <?php while ( have_posts() ) : the_post();
  8.  
  9. $paged_string = is_home() || is_front_page() ? 'page' : 'paged';
  10. $paged = get_query_var( $paged_string ) ? get_query_var( $paged_string ) : 1;
  11.  
  12. $args = array(
  13. 'paged' => $paged,
  14. 'post_type' => 'post',
  15. 'cat' => 1,
  16. 'posts_per_page' => 5
  17. );
  18. $all_posts = new WP_Query( $args );
  19.  
  20. $style = get_post_meta( $post->ID, 'krown_blog_style', true );
  21.  
  22. while ( $all_posts->have_posts() ) : $all_posts->the_post();
  23.  
  24. get_template_part( 'content' );
  25.  
  26.  
  27. endwhile;
  28.  
  29.  
  30. endwhile; ?>
  31.  
  32. krown_pagination( $all_posts, true );
  33.  
  34. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement