bdbrown

All-Posts Archive Page

Feb 2nd, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.67 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Template Name: All-Posts Archive Page
  4.  */
  5. ?>
  6.  
  7. <?php get_header(); ?>
  8.  
  9. <section class="content">
  10.  
  11.     <?php get_template_part('inc/page-title'); ?>
  12.    
  13.     <div class="pad group">    
  14.        
  15.         <?php if ((category_description() != '') && !is_paged()) : ?>
  16.             <div class="notebox">
  17.                 <?php echo category_description(); ?>
  18.             </div>
  19.         <?php endif; ?>
  20.        
  21.  
  22.   <?php
  23.     // Add custom query to retrieve all posts
  24.  
  25.     // set up archive arguments
  26.     $archive_args = array(
  27.       post_type => 'post',    // get only posts
  28.       'posts_per_page'=> -1   // this will display all posts on one page
  29.     );
  30.  
  31.     // new instance of WP_Quert
  32.     $archive_query = new WP_Query( $archive_args );
  33.  
  34.   ?>
  35.  
  36.         <?php if ( have_posts() ) : ?>
  37.        
  38.             <?php if ( ot_get_option('blog-standard') == 'on' ): ?>
  39.            
  40.                 <!-- use the custom query -->
  41.                 <?php while ( $archive_query->have_posts() ): $archive_query->the_post(); ?>
  42.            
  43.                     <?php get_template_part('content-standard'); ?>
  44.                 <?php endwhile; ?>
  45.             <?php else: ?>
  46.             <div class="post-list group">
  47.            
  48.                 <!-- use the custom query -->
  49.                 <?php $i = 1; echo '<div class="post-row">'; while ( $archive_query->have_posts() ): $archive_query->the_post(); ?>
  50.            
  51.                     <?php get_template_part('content'); ?>
  52.                 <?php if($i % 2 == 0) { echo '</div><div class="post-row">'; } $i++; endwhile; echo '</div>'; ?>
  53.             </div><!--/.post-list-->
  54.             <?php endif; ?>
  55.        
  56.             <?php get_template_part('inc/pagination'); ?>
  57.            
  58.         <?php endif; ?>
  59.        
  60.     </div><!--/.pad-->
  61.    
  62. </section><!--/.content-->
  63.  
  64.   <?php wp_reset_postdata(); // always reset post data after a custom query ?>
  65.  
  66. <?php get_sidebar(); ?>
  67.  
  68. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment