display-featured.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * The template for displaying featured content
  4. *
  5. * @package TextBook
  6. */
  7. // Get featured content data
  8. $featured_content = textbook_get_featured_content();
  9. // Get featured content settings and options
  10. $featured_options = get_option( 'featured-content' );
  11. $featured_page_id = absint( get_theme_mod( 'featured_page' ) );
  12. $featured_page_title = get_theme_mod( 'featured_page_title' );
  13. $featured_page_description = get_theme_mod( 'featured_page_description' );
  14. // Set featured title from tag name of theme options
  15. if ( empty( $featured_page_title ) && ! empty( $featured_options[ 'tag-name' ] ) ) {
  16. $featured_page_title = $featured_options[ 'tag-name' ];
  17. } else {
  18. $featured_page_title = $featured_page_title;
  19. }
  20. // Set featured description from tag description of theme options
  21. if ( empty( $featured_page_description ) && ! empty( $featured_options[ 'tag-description' ] ) ) {
  22. $featured_page_description = $featured_options[ 'tag-description' ];
  23. } else {
  24. $featured_page_description = $featured_page_description;
  25. } ?>
  26. <?php /* if we have featured content OR a featured page */ ?>
  27. <?php if ( ! empty( $featured_content ) || ! empty( $featured_page_id ) ) { ?>
  28. <div id="featured-content" class="featured-content">
  29. <div class="featured-content-header-wrap">
  30. <header class="featured-content-header">
  31. <h1 class="featured-content-title"><?php echo esc_html( $featured_page_title ); ?></h1>
  32. <?php if ( $featured_page_description ) { ?>
  33. <div class="featured-content-description">
  34. <?php echo apply_filters( 'the_content', $featured_page_description ); ?>
  35. </div>
  36. <?php } ?>
  37. </header>
  38. <?php // Add template for Featured Highlight
  39. get_template_part( 'components/features/featured-content/content', 'page-highlight' ); ?>
  40. </div>
  41. <?php /* if has featured content */ ?>
  42. <?php if ( ! empty( $featured_content ) ) { ?>
  43. <div class="featured-content-inner">
  44. <?php // Ignore the Highlighted (first) featured content
  45. $ignore_highlight_content = true;
  46. $i = 1;
  47. foreach ( $featured_content as $post ) {
  48. setup_postdata( $post );
  49. if ( $i <= 3 ) {
  50. if ( 1 !== count( $featured_content ) ) {
  51. // Include the standard featured content template.
  52. get_template_part( 'components/features/featured-content/content', 'featured' );
  53. } else {
  54. // Include the full width featured image template.
  55. get_template_part( 'components/features/featured-content/content', 'featured-full' );
  56. }
  57. $i++;
  58. } else {
  59. // Skip other featured content
  60. continue;
  61. }
  62. }
  63. wp_reset_postdata(); ?>
  64. </div>
  65. <?php } ?>
  66. </div>
  67. <?php } ?>