Betiok
9/18/2017 - 11:25 AM

mixItUp

<?php
	$queried_object = get_queried_object();

	$taxonomy_name = 'gallery-tags';

	$parent_terms = get_terms( array(
		'taxonomy' => $taxonomy_name,
		'hide_empty' => true,
		'parent' => 0
	) );
?>

<div class="controls filters">
	<li class="parent-title">
		<span class="control" data-filter="all">
			<?php _e( 'View All', 'html5blank' ); ?>
		</span>
	</li>

	<?php foreach ($parent_terms as $parent_term) : ?>
		<?php
			$child_terms = get_terms(array(
				'parent'   => $parent_term->term_id,
				'taxonomy' => $taxonomy_name,
				'hide_empty' => true
			));

			if($child_terms) {
				$class = 'has-children';
				$filter = '';
			} else {
				$class = 'no-children';
				$filter = '.' . $parent_term->slug;
			}
		?>

		<ul class="filter-group">
			<li class="parent-title <?php echo $class; ?>">
				<span class="control" data-filter="<?php echo $filter; ?>">
					<?php echo $parent_term->name; ?>
				</span>
			</li>

			<?php if ($child_terms) : ?>
				<ul class="sub-menu">
					<?php foreach ($child_terms as $child_term) : ?>
						<li class="child-title">
							<span class="control" data-filter=".<?php echo $child_term->slug; ?>">
								<?php echo $child_term->name; ?>
							</span>
						</li>
					<?php endforeach; ?>
				</ul>
			<?php endif; ?>
		</ul>
	<?php endforeach; ?>

	<?php wp_reset_query(); ?>
</div>
<div class="columns columns-2 short mixitup-container">
	<?php if ($loop ->have_posts()): while ($loop->have_posts()) : $loop->the_post(); ?>
		<?php
			$classes = '';
			$tags = wp_get_post_terms($post->ID, 'gallery-tags');

			foreach ($tags as $tag) {
				$classes .= ' ' . $tag->slug;
			}
		?>

		<article id="post-<?php the_ID(); ?>" <?php post_class('col mix' . $classes); ?>>

		</article>
	<?php endwhile; ?>

	<?php endif; ?>

	<?php wp_reset_query(); ?>
</div>
if (is_page_template('template-gallery.php')) {
	wp_register_script('mixitup', get_stylesheet_directory_uri() . '/js/mixitup.min.js', array('jquery'), '3.2.1');
	wp_enqueue_script('mixitup');

	wp_register_script('mixitupinit', get_stylesheet_directory_uri() . '/js/mixitupinit.js', array('jquery'), '1.0.0');
	wp_enqueue_script('mixitupinit');
}