content-featured.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * The template for displaying featured content
  4. *
  5. * @package Canard
  6. */
  7. $featured_posts = apostrophe_2_get_featured_posts();
  8. if ( empty( $featured_posts ) ) {
  9. return;
  10. }
  11. ?>
  12. <div id="featured-content" class="featured-content">
  13. <?php
  14. $count = 1;
  15. foreach ( $featured_posts as $post ) {
  16. setup_postdata( $post );
  17. ?>
  18. <article id="post-<?php the_ID(); ?>" <?php post_class( 'apostrophe-2-featured' ); ?>>
  19. <?php
  20. if ( apostrophe_2_has_post_thumbnail() ) {
  21. $apostrophe_2_has_thumbnail = 'apostrophe-2-thumb';
  22. // The grid of featured content posts uses smaller image size for items 2,3,6,7,10,11 etc.
  23. if ( ( ( ( $count - 2 ) / 4) * 10 ) % 10 == 0 || ( ( ( $count - 3 ) / 4) * 10 ) % 10 == 0 ) {
  24. $thumbnail = get_the_post_thumbnail( $post->ID );
  25. } else {
  26. $thumbnail = get_the_post_thumbnail( $post->ID, 'apostrophe-2-featured' );
  27. }
  28. } else {
  29. $apostrophe_2_has_thumbnail = 'apostrophe-2-nothumb';
  30. $thumbnail = '<span></span>';
  31. } ?>
  32. <a class="entry-thumbnail <?php echo esc_attr( $apostrophe_2_has_thumbnail ); ?>" href="<?php echo esc_url( get_permalink() ); ?>">
  33. <?php echo wp_kses_post( $thumbnail ); ?>
  34. </a>
  35. <header class="entry-header">
  36. <div class="entry-meta">
  37. <?php apostrophe_2_posted_on(); ?>
  38. </div><!-- .entry-meta -->
  39. <h2 class="entry-title"><a href="<?php echo esc_url( get_permalink() ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  40. </header><!-- .entry-header -->
  41. </article><!-- #post-## -->
  42. <?php
  43. $count++;
  44. }
  45. wp_reset_postdata();
  46. ?>
  47. </div><!-- #featured-content -->