Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A Wordpress front-page template for a custom theme that leverages the Advanced Custom Fields plugin to create a completely dynamic homepage that's easy for content creators to update.
<?php
get_header();
global $slider_meta;
?>
<?php
// Start the loop.
while (have_posts()) : the_post();
// If comments are open or we have at least one comment, load up the comment template.
if (comments_open() || get_comments_number()) :
comments_template();
endif;
// End the loop.
endwhile;
?>
<section class="slideshow-container">
<?php
$description = get_bloginfo('description', 'display');
if ($description || is_customize_preview()) : ?>
<p class="site-description"><?php echo $description; ?></p>
<?php endif; ?>
<section>
<div id="slider" class="nivoSlider">
<?php while ($slider_meta->have_fields('slides')): ?>
<img src='<?php $slider_meta->the_value('imgurl'); ?>'alt='<?php $slider_meta->the_value('slide_title') ?>' title="<?php $slider_meta->the_value('slide_caption'); ?>">
<?php endwhile; ?>
<div class="caption-show">
<div class="svg-camera">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="102px" height="83px"
viewBox="0 0 102 83" style="enable-background:new 0 0 102 83;" xml:space="preserve">
<style type="text/css">
.camera-styles {
fill: #F8F5EC;
}
</style>
<path class="camera-styles"
d="M51,32.9c-9.3,0-16.8,7.5-16.9,16.9c0,9.3,7.5,16.8,16.9,16.9c9.3,0,16.8-7.5,16.9-16.9 C67.8,40.4,60.3,32.9,51,32.9z M96,18.9H78.8L77.5,3.6c0-1.4-1.2-2.6-2.6-2.6H27.1c-1.5,0-2.6,1.2-2.6,2.6l-1.3,15.3h-3v-3.4 c0-1.2-1-2.2-2.2-2.2H8.3c-1.2,0-2.2,1-2.2,2.2v3.4H6c-2.7,0-5,2.2-5,5v53.2c0,2.7,2.2,5,5,5H96c2.7,0,5-2.2,5-5V23.9 C101,21.1,98.8,18.9,96,18.9z M13.2,39.7C9.8,39.7,7,37,7,33.6c0-3.4,2.8-6.2,6.2-6.2c3.4,0,6.2,2.8,6.2,6.2 C19.3,37,16.6,39.7,13.2,39.7z M38.2,7.7h25.7c1.6,0,2.9,1.3,2.9,2.9c0,1.6-1.3,2.9-2.9,2.9H38.2c-1.6,0-2.9-1.3-2.9-2.9 C35.3,9,36.6,7.7,38.2,7.7z M51,74.2c-13.5,0-24.5-11-24.5-24.5c0-13.5,11-24.5,24.5-24.5c13.5,0,24.5,11,24.5,24.5 C75.5,63.3,64.5,74.2,51,74.2z"/>
</svg>
</div>
</div>
</div>
<!-- <span class="dashicons dashicons-camera caption-show"></span>-->
</section>
</section>
<div id="primary" class="content-area">
<?php if (have_rows('featured_item')): ?>
<section class="featured-content">
<div class="row around">
<?php while (have_rows('featured_item')): the_row(); ?>
<?php
$icon = get_sub_field('icon');
if ($icon): ?>
<div class="row centered">
<div class="top-feature col col-6">
<img src="<?php echo $icon; ?>">
<h2 class="h2"><?php the_sub_field('title'); ?></h2>
<?php the_sub_field('description'); ?>
<a href="<?php the_sub_field('link'); ?>"><?php the_sub_field('link_title'); ?></a>
</div>
</div>
<?php else : ?>
<div class="regular-feature col col-4">
<h2><?php the_sub_field('title'); ?></h2>
<?php the_sub_field('description'); ?>
<a href="<?php the_sub_field('link'); ?>"><?php the_sub_field('link_title'); ?></a>
</div>
<?php endif; ?>
<?php endwhile; ?>
</div>
</section>
<?php endif; ?>
<?php if (is_active_sidebar('sidebar-news')) : ?>
<aside id="news" class="sidebar widget-area" role="complementary">
<?php dynamic_sidebar('sidebar-news'); ?>
</aside><!-- .sidebar .widget-area -->
<?php endif; ?>
<?php if (have_rows('call_to_action')): ?>
<section class="calls-to-action">
<div class="cta-container">
<div class="row">
<?php while (have_rows('call_to_action')): the_row(); ?>
<div class="cta-item col col-4">
<a href="<?php the_sub_field('cta_link'); ?>">
<img src="<?php the_sub_field('cta_icon'); ?>">
<h2><?php the_sub_field('cta_title'); ?></h2>
<?php the_sub_field('cta_caption'); ?>
</a>
</div>
<?php endwhile; ?>
</div>
</div>
</section><!-- call to actions -->
<?php endif; ?>
</div><!-- .content-area -->
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment