PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/themes/news/page-template-home.php

https://bitbucket.org/lgorence/quickpress
PHP | 196 lines | 105 code | 77 blank | 14 comment | 14 complexity | 40641b78509a4bea7a0512380d5957df MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, AGPL-1.0
  1. <?php
  2. /**
  3. * Template Name: Home
  4. *
  5. * Used as a news-type home page. It lists a featured section at the top and pulls in the sidebar-feature.php
  6. * file to sit beside the featured area. In the normal content area, posts are listed by category. These
  7. * categories must be selected in the 'Home Template Settings' section of the 'News Settings' page. After
  8. * the category highlight section, a more articles section displays a set number of posts.
  9. *
  10. * @package News
  11. * @subpackage Template
  12. */
  13. /* Set up a default array for posts we're not duplicating. */
  14. $do_not_duplicate = array();
  15. get_header(); ?>
  16. <!-- Begin feature area. -->
  17. <div id="feature">
  18. <!-- Begin slideshow. -->
  19. <div class="slideshow-set">
  20. <div class="slideshow-items">
  21. <?php
  22. /* Get the sticky posts. */
  23. $sticky = get_option( 'sticky_posts' );
  24. /* If more than one sticky post, use them for the slider. Else, just get the 3 latest posts. */
  25. $args = ( ( !empty( $sticky ) && 1 < count( $sticky ) ) ? array( 'post__in' => $sticky ) : array( 'posts_per_page' => 5 ) );
  26. ?>
  27. <?php $loop = new WP_Query( $args ); $i = 0; ?>
  28. <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
  29. <?php $do_not_duplicate[] = get_the_ID(); ?>
  30. <div class="<?php hybrid_entry_class( 'slideshow-item item item-' . ++$i ); ?>">
  31. <?php get_the_image( array( 'meta_key' => array( 'Large' ), 'size' => 'news-slideshow-large' ) ); ?>
  32. <?php echo apply_atomic_shortcode( 'entry_title', the_title( '<h2 class="entry-title"><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '">', '</a></h2>', false ) ); ?>
  33. <div class="slideshow-caption">
  34. <div class="entry-summary slideshow-caption-text"><?php the_excerpt(); ?></div>
  35. </div><!-- .slideshow-caption -->
  36. </div><!-- .hentry -->
  37. <?php endwhile; ?>
  38. </div><!-- .slideshow-items -->
  39. <div class="slideshow-controls">
  40. <div class="slideshow-pager"></div>
  41. <div class="slideshow-nav">
  42. <a class="slider-prev"><?php _e( 'Previous', 'news' ); ?></a>
  43. <a class="slider-next"><?php _e( 'Next', 'news' ); ?></a>
  44. </div>
  45. </div><!-- .slideshow-controls -->
  46. </div><!-- .slideshow-set -->
  47. <!-- End slideshow. -->
  48. <?php get_sidebar( 'feature' ); ?>
  49. </div>
  50. <!-- End feature area. -->
  51. <?php do_atomic( 'before_content' ); // Before content hook ?>
  52. <div id="content">
  53. <?php do_atomic( 'open_content' ); // Open content hook ?>
  54. <div class="hfeed">
  55. <!-- Begin category highlight section. -->
  56. <?php $categories = hybrid_get_setting( 'home_template_categories' ); ?>
  57. <?php if ( !empty( $categories ) && is_array( $categories ) ) { ?>
  58. <!-- Begin category section. -->
  59. <div id="category-highlight">
  60. <?php foreach ( $categories as $category ) { ?>
  61. <?php $loop = new WP_Query( array( 'cat' => $category, 'posts_per_page' => 6, 'post__not_in' => $do_not_duplicate ) ); ?>
  62. <?php if ( $loop->have_posts() ) : ?>
  63. <div class="section category-section">
  64. <div class="section-wrap category-section-wrap">
  65. <?php $term = get_term( $category, 'category' ); ?>
  66. <h2 class="category-title section-title"><a href="<?php echo get_term_link( $term, 'category' ); ?>" title="<?php echo esc_attr( $term->name ); ?>"><?php echo $term->name; ?></a></h2>
  67. <?php $i = 0; ?>
  68. <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
  69. <?php $do_not_duplicate[] = get_the_ID(); ?>
  70. <?php if ( ++$i == 1 ) { // If first post, show title, excerpt, and image. ?>
  71. <div class="<?php hybrid_entry_class(); ?>">
  72. <?php echo apply_atomic_shortcode( 'entry_title', the_title( '<h3 class="entry-title"><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h3>', false ) ); ?>
  73. <?php get_the_image( array( 'meta_key' => array( 'Thumbnail' ), 'size' => 'news-thumbnail' ) ); ?>
  74. <div class="entry-summary">
  75. <?php the_excerpt(); ?>
  76. </div><!-- .entry-summary -->
  77. </div><!-- .hentry -->
  78. <?php } else { // If not the first post, add the entry titles as list items. ?>
  79. <?php if ( $i == 2 ) echo '<ul class="xoxo post-list">'; // If second post, open the list. ?>
  80. <li>
  81. <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" rel="bookmark"><?php the_title(); ?></a>
  82. <?php echo apply_atomic_shortcode( 'entry_meta', '<div class="entry-meta">[entry-published] [entry-comments-link before=" // "]</div>' ); ?>
  83. </li>
  84. <?php } ?>
  85. <?php endwhile; ?>
  86. <?php if ( $i > 1 ) echo '</ul>'; // If there is more than one post, close the list after the loop. ?>
  87. </div><!-- .section-wrap -->
  88. </div><!-- .section -->
  89. <!-- End category section. -->
  90. <?php endif; ?>
  91. <?php } ?>
  92. </div><!-- .category-highlight -->
  93. <?php } ?>
  94. <!-- End category highlight section. -->
  95. <!-- Begin more articles section. -->
  96. <?php $loop = new WP_Query( array( 'posts_per_page' => 3, 'post__not_in' => $do_not_duplicate ) ); ?>
  97. <?php if ( $loop->have_posts() ) : ?>
  98. <div id="more-articles" class="section">
  99. <div class="section-wrap">
  100. <h2 class="section-title"><?php _e( 'More Articles', 'news' ); ?></h2>
  101. <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
  102. <div class="<?php hybrid_entry_class(); ?>">
  103. <?php get_the_image( array( 'meta_key' => array( 'Thumbnail' ), 'size' => 'news-thumbnail' ) ); ?>
  104. <?php echo apply_atomic_shortcode( 'entry_title', the_title( '<h3 class="entry-title"><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h3>', false ) ); ?>
  105. <?php echo apply_atomic_shortcode( 'byline', '<div class="byline">[entry-published] [entry-comments-link] [entry-popup-shortlink]</div>' ); ?>
  106. <div class="entry-summary">
  107. <?php the_excerpt(); ?>
  108. </div><!-- .entry-summary -->
  109. </div><!-- .hentry -->
  110. <?php endwhile; ?>
  111. </div><!-- .section-wrap -->
  112. </div><!-- .section -->
  113. <?php endif; ?>
  114. <!-- End more articles section. -->
  115. </div><!-- .hfeed -->
  116. <?php do_atomic( 'close_content' ); // Close content hook ?>
  117. </div><!-- #content -->
  118. <?php do_atomic( 'after_content' ); // After content hook ?>
  119. <?php get_footer(); ?>