G2A Many GEOs
SHARE
TWEET

WordPress Pagination Issues

mikeoberdick Mar 27th, 2016 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. //* Template Name: Homepage Blog
  4. //* Displays the default editor content followed by blog posts from all categories
  5.  
  6. get_header ();
  7.  
  8. do_action( 'genesis_before_content_sidebar_wrap' );
  9.     genesis_markup( array(
  10.         'html5'   => '<div %s>',
  11.         'xhtml'   => '<div id="content-sidebar-wrap">',
  12.         'context' => 'content-sidebar-wrap',
  13.     ) );
  14.  
  15. //* Display the default WordPress editor content
  16.  
  17. if ( have_posts() ) : while ( have_posts() ) : the_post();?>
  18.  
  19.     <?php the_content (); ?>
  20.     <?php endwhile;
  21.     else : //* if no posts exist
  22.     do_action( 'genesis_loop_else' );
  23.     endif; //* end loop
  24.  
  25. do_action( 'genesis_before_content' );
  26.     genesis_markup( array(
  27.         'html5'   => '<main %s>',
  28.         'xhtml'   => '<div id="content" class="hfeed">',
  29.         'context' => 'content',
  30.         ) );
  31.  
  32. //* Create a new loop to display the blog posts
  33.  
  34. $custom_query_args = array (
  35.     'post_type' => 'post',
  36.     'posts_per_page' => 10,
  37. );
  38.  
  39. $custom_query_args['paged'] = get_query_var( 'page' ) ? get_query_var( 'page' ) : 1;
  40.  
  41. $hp_blog_posts = new WP_Query ( $custom_query_args );
  42.  
  43. // Pagination fix
  44. $temp_query = $wp_query;
  45. $wp_query   = NULL;
  46. $wp_query   = $hp_blog_posts;
  47.  
  48. do_action( 'genesis_before_loop' );
  49.  
  50. if ( $hp_blog_posts->have_posts() ) :
  51.  
  52. do_action( 'genesis_before_while' );
  53.  
  54. while ( $hp_blog_posts->have_posts() ) : $hp_blog_posts->the_post();
  55.  
  56. do_action( 'genesis_before_entry' );
  57.  
  58. printf( '<article %s>', genesis_attr( 'entry' ) );
  59.  
  60. do_action( 'genesis_before_entry_content' );
  61.  
  62. if ( has_post_thumbnail() ) {
  63. the_post_thumbnail('full');
  64. }
  65.  
  66. echo '<h2 class="entry-title" itemprop="headline"><a href = "' . get_permalink () . '" rel="bookmark">' . get_the_title () . '</a></h2>';
  67.  
  68. echo '<p class="read_more"><a href = "' . get_permalink() . '">READ MORE</a></p>';
  69.  
  70. do_action( 'genesis_after_entry_content' );
  71.  
  72. echo '</article>';
  73.  
  74. do_action( 'genesis_after_entry' );
  75.  
  76. endwhile; //* end of one post
  77. do_action( 'genesis_after_endwhile' );
  78.  
  79. else : //* if no posts exist
  80. do_action( 'genesis_loop_else' );
  81. endif; //* end loop
  82. do_action( 'genesis_after_loop' );
  83.  
  84. // Reset postdata
  85. wp_reset_postdata();
  86.  
  87. // Reset main query object
  88. $wp_query = NULL;
  89. $wp_query = $temp_query;
  90.  
  91. genesis_markup( array(
  92.         'html5' => '</main>', //* end .content
  93.         'xhtml' => '</div>', //* end #content
  94.         ) );
  95.        
  96. do_action( 'genesis_after_content' );
  97.  
  98. echo '</div>'; //* end .content-sidebar-wrap or #content-sidebar-wrap
  99.  
  100. do_action( 'genesis_after_content_sidebar_wrap' );
  101.  
  102. get_footer ();
  103.  
  104. ?>
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top