Skip to content

Instantly share code, notes, and snippets.

@wilhelser
Created February 26, 2015 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilhelser/62cbcf451ca0a6ee2561 to your computer and use it in GitHub Desktop.
Save wilhelser/62cbcf451ca0a6ee2561 to your computer and use it in GitHub Desktop.
Dakotas Gallery
<?php
/* Template Name: Gallery */
get_header(); ?>
<main role="main">
<section class="hero gallery-hero">
<div class="menus-headline">
<h1>Gallery</h1>
</div>
</section>
<section class="gallery-container">
<div class="row">
<div class="col-md-12">
<?php if (have_posts()): ?>
<?php while (have_posts()) : the_post(); ?>
<?php if( get_post_gallery() ) : ?>
<?php
$gallery = get_post_gallery( get_the_ID(), false );
$ids = explode(',', $gallery['ids']);
?>
<div id="gallery-masonry">
<?php
foreach ($ids as $id) {
?>
<div class="item">
<?php echo wp_get_attachment_image( $id, 'full' ); ?>
<a class="fancybox" rel="gallery" href="<?php echo wp_get_attachment_image_src( $id, 'full' )[0]; ?>" title="<?php echo get_the_title($id); ?>" >
<div class="item-description">
<div class="item-title">
<p>View</p>
</div>
</div>
</a>
</div>
<?php
}
?>
</div>
<?php else : ?>
You need to add a gallery to this section.
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
</div>
</div>
</section>
</main>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment