Advertisement
endlyss

Custom Archive Template Part

Jun 19th, 2014
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.57 KB | None | 0 0
  1. <div class="mpostfeed <?php echo $req_year.'-'.$req_month.'-'.$req_day;?>-archives archive-template" >
  2.     <header class="header">
  3.         <h1 class="mp-main-title"><?php
  4.         if ( is_day() ) { printf( __( 'Daily Archives: %s', 'Evyr2014' ), get_the_time(get_option('date_format') ) ); }
  5.         elseif ( is_month() ) { printf( __( 'Monthly Archives: %s', 'Evyr2014' ), get_the_time('F Y') ); }
  6.         elseif ( is_year() ) { printf( __( 'Yearly Archives: %s', 'Evyr2014' ), get_the_time('Y') ); }
  7.         else { _e( 'Archives', 'Evyr2014' ); }
  8.         ?></h1>
  9.     </header>
  10.     <ul>
  11.     <?php
  12.         /*--------------------------------------------------------------------
  13.         --Set up the arguments for the query, including the paginated aspect--
  14.         --------------------------------------------------------------------*/
  15.         $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  16.         evyr2014_date_from_url();
  17.         global $req_day, $req_month, $req_year, $the_query;
  18.         if($req_day & $req_month & $req_year){
  19.             $args = array(
  20.             'post_type' => 'post',
  21.             'cat' => '-14',
  22.             'date_query' => array(
  23.                     array(
  24.                         'day' => $req_day,
  25.                         'year' => $req_year,
  26.                         'month'=> $req_month,
  27.                     )
  28.                 ),
  29.             'posts_per_page' => 10,
  30.             'paged' => $paged
  31.             );
  32.         }elseif(empty($req_day)){
  33.             $args = array(
  34.             'post_type' => 'post',
  35.             'cat' => '-14',
  36.             'date_query' => array(
  37.                     array(
  38.                         'year' => $req_year,
  39.                         'month'=> $req_month,
  40.                     )
  41.                 ),
  42.             'posts_per_page' => 10,
  43.             'paged' => $paged
  44.             );
  45.         }else{
  46.             $args = array(
  47.             'post_type' => 'post',
  48.             'cat' => '-14',
  49.             'date_query' => array(
  50.                     array(
  51.                         'month'=> $req_month,
  52.                     )
  53.                 ),
  54.             'posts_per_page' => 10,
  55.             'paged' => $paged
  56.             );
  57.         }
  58.        
  59.         /*-------------------------------------------------
  60.         --Retrieve the query based on the above arguments--
  61.         -------------------------------------------------*/
  62.         $the_query = new WP_Query( $args );
  63.         if ( $the_query->have_posts() ) :
  64.             while ( $the_query->have_posts() ) : $the_query->the_post();
  65.             /*---------------------
  66.             --Begin the post item--
  67.             ---------------------*/
  68.             ?>
  69.             <li class="post-item">
  70.                 <a href="<?php echo the_permalink();?>">
  71.                     <span class="featured-bg">
  72.                         <?php
  73.                         if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
  74.                             the_post_thumbnail();
  75.                         }else{ ?>
  76.                             <span class="fp-holder"></span>
  77.                         <?php }
  78.                         ?>
  79.                     </span>
  80.                 </a>
  81.                 <a href="<?php echo get_permalink();?>" class="mp-title"><?php the_title();?></a>
  82.                 <span class="mp-excerpt"><?php the_excerpt();?></span>
  83.                 <span class="mp-panel">
  84.                     <span class="mp-date">
  85.                         <?php
  86.                             /*--------------------------------------------------
  87.                             --Sets up the Date in [Month] [Day], [Year] Format--
  88.                             --------------------------------------------------*/
  89.                             the_time('F d, Y');
  90.                         ?>
  91.                     </span>
  92.                     <span class="mp-postcount">
  93.                         <?php
  94.                         /*--Retrieve the post view count for the designated post--*/
  95.                         echo getPostViews(get_the_ID());
  96.                         ?>
  97.                     </span>
  98.                     <a href="<?php echo get_permalink();?>" class="mp-readmore">Read More</a>
  99.                     <span class="divider"></span>
  100.                 </span>
  101.             </li><!--/.post-item-->
  102.         <?php
  103.  
  104.           ?>
  105.           <?php endwhile; ?>
  106.     </ul>
  107.     <?php
  108.     get_template_part('assets/parts/feed', 'pagination');
  109.     /*---------------------------------
  110.     --Reset the arguments and query,---
  111.     --So that multiple queries may be--
  112.     --set up in a template-------------
  113.     ---------------------------------*/
  114.     wp_reset_postdata(); ?>
  115.     <?php else:
  116.       //Do Nothing
  117.     endif; ?>
  118.    
  119. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement