PageRenderTime 36ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/themes/OneMozilla/archive.php

https://github.com/fvignals/One-Mozilla-blog
PHP | 68 lines | 52 code | 15 blank | 1 comment | 11 complexity | 81ade78a462ebf76ac68d819f863f7ce MD5 | raw file
  1. <?php
  2. // Count search results
  3. global $wp_query;
  4. $total_results = $wp_query->found_posts;
  5. get_header(); ?>
  6. <div id="content-main" class="main" role="main">
  7. <?php if ( have_posts() ) : ?>
  8. <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
  9. <h1 class="page-title">
  10. <?php if (is_category()) : ?><?php printf(__('Archive for %s','onemozilla'), single_cat_title()); ?>
  11. <?php elseif (is_tag()) : ?><?php printf(__('Posts tagged with “%s”','onemozilla'), single_tag_title()); ?>
  12. <?php elseif (is_day()) : ?><?php printf(__('Posts from %s', 'onemozilla'), get_the_date()); ?>
  13. <?php elseif (is_month()) : ?><?php printf(__('Posts from %s', 'onemozilla'), get_the_date('F, Y')); ?>
  14. <?php elseif (is_year()) : ?><?php printf(__('Posts from %s', 'onemozilla'), get_the_date('Y')); ?>
  15. <?php elseif (is_author()) : ?><?php printf(__('Posts by %s','onemozilla'), esc_html(get_userdata(intval($author))->display_name) ); ?></span>
  16. <?php elseif (is_search()) : ?><?php printf( _n('We found one result for “%2$s”', 'We found %1$s results for “%2$s”', $total_results, 'onemozilla'), $total_results, esc_html(get_search_query()) ); ?>
  17. <?php else : ?><?php _e('Archives','onemozilla'); ?>
  18. <?php endif; ?>
  19. </h1>
  20. <?php if (fc_show_posts_nav()) : ?>
  21. <nav class="nav-paging top">
  22. <ul role="navigation">
  23. <?php if ( $paged < $wp_query->max_num_pages ) : ?><li class="prev"><?php next_posts_link(__('Older posts','onemozilla')); ?></li><?php endif; ?>
  24. <?php if ( $paged > 1 ) : ?><li class="next"><?php previous_posts_link(__('Newer posts','onemozilla')); ?></li><?php endif; ?>
  25. </ul>
  26. </nav>
  27. <?php endif; ?>
  28. <?php /* Start the Loop */ ?>
  29. <?php while ( have_posts() ) : the_post(); ?>
  30. <?php get_template_part( 'content', 'summary' ); ?>
  31. <?php endwhile; ?>
  32. <?php if (fc_show_posts_nav()) : ?>
  33. <nav class="nav-paging bottom">
  34. <ul role="navigation">
  35. <?php if ( $paged < $wp_query->max_num_pages ) : ?><li class="prev"><?php next_posts_link(__('Older posts','onemozilla')); ?></li><?php endif; ?>
  36. <?php if ( $paged > 1 ) : ?><li class="next"><?php previous_posts_link(__('Newer posts','onemozilla')); ?></li><?php endif; ?>
  37. </ul>
  38. </nav>
  39. <?php endif; ?>
  40. <?php else : ?>
  41. <article id="post-0" class="post no-results not-found">
  42. <header class="entry-header">
  43. <h1 class="entry-title"><?php _e( 'Nothing Found', 'onemozilla' ); ?></h1>
  44. </header><!-- .entry-header -->
  45. <div class="entry-content">
  46. <p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'onemozilla' ); ?></p>
  47. <?php get_search_form(); ?>
  48. </div><!-- .entry-content -->
  49. </article><!-- #post-0 -->
  50. <?php endif; ?>
  51. </div><!-- #content-main -->
  52. <?php get_sidebar(); ?>
  53. <?php get_footer(); ?>