forked from dimsemenov/Touchfolio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ds-gallery-masonry-template.php
80 lines (77 loc) · 2.11 KB
/
ds-gallery-masonry-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
76
77
78
79
80
<?php
/**
*
* Template Name: Masonry Gallery 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">
<?php
// filter gallery by category set in page content ghetto hack adonnan
global $wp_query;
global $categories_to_show;
$postid = $wp_query->post->ID;
$cnt = get_post($postid);
$cnt = get_object_vars($cnt);
$categories_to_show = $cnt['post_content'];
wp_reset_query();
// END NEW
// CHANGED LINE
$gallery_cats = $categories_to_show;
// END CHANGED LINE
if($gallery_cats) {
$tax_query = array(
'relation' => 'AND',
array(
'taxonomy' => 'ds-gallery-category',
'field' => 'slug',
'terms' => preg_split("/\s*,\s*/", $gallery_cats),
'include_children' => true,
'operator' => 'IN'
)
);
} else {
$tax_query = '';
}
$loop = new WP_Query( array(
'post_type' => 'ds-gallery',
'posts_per_page' => -1,
'tax_query' => $tax_query
));
?>
<section class="albums-thumbnails clearfix">
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<a class="project-thumb" href="<?php the_permalink(); ?>" data-album-id="<?php echo $post->post_name; ?>">
<div class="project-thumb-inside">
<?php
if ( has_post_thumbnail($post->ID) ) {
the_post_thumbnail( 'gallery-thumb' );
} else {
$post_meta = get_post_custom();
$post_meta = unserialize( $post_meta['dsframework-gallery'][0] );
if( isset( $post_meta['attachment_urls'] ) ) {
$image_urls = $post_meta['attachment_ids'];
echo wp_get_attachment_image( $image_urls[0], 'gallery-thumb' );
} else {
echo '<div style="width: 360px; height: 250px; background: grey;">' . __('Album images not found.', 'dsframework') . '</div>';
}
}
?>
<h4 class="project-title"><?php the_title(); ?></h4>
<p class="project-description"><?php echo get_the_excerpt(); ?></p>
</div>
</a>
<?php endwhile; ?>
</section>
<?php wp_reset_postdata(); ?>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>