This repository has been archived by the owner on Feb 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 112
/
ds-gallery-categories-navigation-template.php
75 lines (63 loc) · 2.33 KB
/
ds-gallery-categories-navigation-template.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
*
* Template Name: Gallery Categories Navigation Page
*
* The template for displaying gallery page with masonry layout.
*
* @package dsframework
* @since dsframework 1.0
*
*/
?>
<?php get_header(); ?>
<div id="primary" class="site-content">
<div id="content" role="main">
<?
$permalink = get_permalink();
$post_meta = get_post_custom();
$visible_gallery_categories = array();
$gallery_category_slug="";
if(isset($_GET) && isset($_GET['category'])) $gallery_category_slug=$_GET['category'];
if($gallery_category_slug=="") $gallery_category_slug = $post_meta['dsframework-root-gallery-category'][0];
if($gallery_category_slug=="" && isset($post_meta['dsframework-visible-gallery-categories'][0])) $visible_gallery_categories = explode(",", $post_meta['dsframework-visible-gallery-categories'][0]);
if(count($visible_gallery_categories)>0){
foreach ( $visible_gallery_categories as $subgallery_category_slug ){
$category=get_gallery_category_by_slug( trim( $subgallery_category_slug) );
if($category!=null) $categories[]=$category;
}
}else if($gallery_category_slug!=""){
$gallery_category=get_gallery_category_by_slug($gallery_category_slug);
$categories = get_gallery_categories(array('hide_empty' => 0, 'parent' => $gallery_category->term_id));
}else{
$categories = get_gallery_categories(array('hide_empty' => 0));
}
?>
<section class="albums-thumbnails clearfix">
<?php
foreach ( $categories as $subcategory ) {
$subcategory->navigation_link=add_query_arg( array('category' => $subcategory->slug), $permalink);
$GLOBALS['category']=$subcategory;
if($subcategory->parent==0 || ($gallery_category_slug!="" && $subcategory->parent==$gallery_category->term_id) || count($visible_gallery_categories)>0){
$postLoop = post_in_gallery_category( $subcategory, true );
if( $postLoop->have_posts() ) {
$postLoop->the_post();
get_template_part( 'content', 'categories-navigation' );
}
}
}
if(isset($gallery_category)){
$postLoop = post_in_gallery_category( $gallery_category );
while ( $postLoop->have_posts() ) {
$postLoop->the_post();
get_template_part( 'content', 'masonry' );
}
}
?>
</section>
<?php wp_reset_postdata(); ?>
<?php get_template_part( 'content', 'page-masonry' ); ?>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>