Advertisement
alchymyth

archive.php loop

Oct 29th, 2017
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.13 KB | None | 0 0
  1. <?php define( 'WP_USE_THEMES', false ); get_header(); ?>
  2.  
  3. <?php if ( have_posts() ) : ?>
  4.     <main>
  5.         <div class="archive">
  6.             <div class="col-03">&nbsp;</div>
  7.             <div class="col-09">
  8.                 <h2>
  9.                     <?php
  10.                         if( is_category() ) {
  11.                             single_cat_title();  // This echos out the categoy name
  12.                         } elseif ( is_tag() ) {
  13.                             single_tag_title();  // This echos out the tag name
  14.                         } elseif ( is_author() ) {
  15.                             the_post(); echo "Posts by " . get_the_author(); rewind_posts();  // This echos out the author name
  16.                         } elseif ( is_day() ) {
  17.                             echo "Daily Archives: " . get_the_date();  // This echos out the day
  18.                         } elseif ( is_month() ) {
  19.                             echo "Monthly Archives: " . get_the_date('F Y');  // This echos out the month and year
  20.                         } elseif ( is_year() ) {
  21.                             echo "Yearly Archives: " . get_the_date('Y');  // This echos out the year
  22.                         }
  23.                         else { echo "Archives"; }
  24.                     ?>
  25.                 </h2>
  26.                 <p>
  27.                     These are the posts filed under the <?php single_cat_title(); ?> category. You will not be able
  28.                     to identify the post content other than the photograph that associates with the post. I've
  29.                     decided that adding text to each photo would just be too much.
  30.                 </p>
  31.             </div>
  32. <?php while ( have_posts() ) : the_post(); ?>
  33.             <div class="archive-gallery">
  34.                 <?php if ( has_post_thumbnail() ) : ?>
  35.                     <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" ><?php the_post_thumbnail(); ?></a>
  36.                 <?php endif; ?>
  37.             </div>
  38. <?php
  39.     endwhile; ?>
  40.         </div>
  41.     </main>
  42.  
  43.         <?php else :
  44.  
  45.             esc_html_e( "Sorry. No posts match your criteria." );
  46.  
  47.     endif; get_footer();
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement