front-page.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * The front page template file.
  4. *
  5. * If the user has selected a static page for their homepage, this is what will
  6. * appear.
  7. * Learn more: http://codex.wordpress.org/Template_Hierarchy
  8. *
  9. * @package Lodestar
  10. */
  11. // Access global variable directly to set content_width
  12. if ( isset( $GLOBALS['content_width'] ) ) {
  13. $GLOBALS['content_width'] = 1120;
  14. }
  15. get_header(); ?>
  16. <div id="primary" class="content-area">
  17. <main id="main" class="site-main" role="main">
  18. <?php // Show the selected frontpage content
  19. if ( have_posts() ) :
  20. while ( have_posts() ) : the_post();
  21. echo '<div class="wrap">';
  22. get_template_part( 'components/page/content', 'front-page' );
  23. echo '</div>';
  24. endwhile;
  25. else : // I'm not sure it's possible to have no posts when this page is shown, but WTH
  26. echo '<div class="wrap">';
  27. get_template_part( 'components/post/content', 'none' );
  28. echo '</div>';
  29. endif; ?>
  30. <?php
  31. // Get each of our panels and show the post data
  32. $panels = array( '1', '2', '3', '4' );
  33. $titles = array();
  34. global $lodestarcounter; // Used in components/page/content-front-page-panels.php file.
  35. if ( 0 !== lodestar_panel_count() || is_customize_preview() ) : //If we have pages to show...
  36. $lodestarcounter = 1;
  37. foreach ( $panels as $panel ) :
  38. if ( get_theme_mod( 'lodestar_panel' . $panel ) ) :
  39. $post = get_post( get_theme_mod( 'lodestar_panel' . $panel ) );
  40. setup_postdata( $post );
  41. set_query_var( 'lodestar_panel', $panel );
  42. $titles[] = get_the_title(); //Put page titles in an array for use in navigation
  43. get_template_part( 'components/page/content', 'front-page-panels' );
  44. wp_reset_postdata();
  45. else :
  46. // output placeholder anchor
  47. echo '<article class="lodestar-panel panel-placeholder">';
  48. echo '<span class="panel lodestar-panel' . esc_attr( $lodestarcounter ) .' label-placeholder" id="panel' . esc_attr( $lodestarcounter ) . '">';
  49. echo '<span class="lodestar-panel-title">' . sprintf( esc_html__( 'Panel %1$s Placeholder', 'lodestar' ), esc_attr( $lodestarcounter ) ) . '</span>';
  50. echo '</span></article>';
  51. endif;
  52. $lodestarcounter++;
  53. endforeach;
  54. ?>
  55. <?php endif; // if ( 0 !== lodestar_panel_count() )
  56. ?>
  57. </main><!-- #main -->
  58. </div><!-- #primary -->
  59. <?php get_footer(); ?>