-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchive-media.php
160 lines (101 loc) · 3.21 KB
/
archive-media.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
/**
* The template for displaying archive pages
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Twenty_Seventeen
* @since 1.0
* @version 1.0
*/
get_header();
?>
<div id="blog" class="blog-home hover-section category-layout">
<div class="category-head">
<h4>Photos</h4>
<div class="bars-animation">
<img src="<?php echo THEME_URL; ?>/dist/assets/img/elements/hicon.png" alt="PM">
</div>
</div><!-- Category Head -->
<div class="row cd-main-content">
<div class="cd-tab-filter-wrapper">
<div class="cd-tab-filter">
<ul class="cd-filters">
</ul>
</div>
</div>
<div class="col-sm-12 col-md-3 col-md-pull-9 sidebar">
<div class="cd-filter filter-is-visible">
<?php if ( is_active_sidebar( 'media' ) ) : ?>
<?php dynamic_sidebar( 'media' ); ?>
<?php else : ?>
Please add Widgets to the "Media" Sidebar under Appearance -> Widgets
<?php endif; ?>
<a href="#0" class="cd-close"><i class="fa fa-times" aria-hidden="true"></i></a>
</div>
<a href="#0" class="cd-filter-trigger"><i class="fa fa-filter" aria-hidden="true"></i> Filters</a>
</div>
<div class="content cd-gallery col-sm-12 col-md-9 col-md-push-3 filter-is-visible">
<?php
if ( have_posts() ) : ?>
<?php
/* Start the Loop */
$index = 0;
$max_per_row = 3; // 0 indexed
while ( have_posts() ) : the_post();
if ( $index == 0 ) : ?>
<div class="row">
<?php endif; ?>
<div <?php post_class( array( 'col-sm-12', 'col-md-3' ) ); ?>>
<div class="background">
<?php
$content = get_the_content();
$did_match = preg_match( '/\[gallery.*?ids="(.*?)"/', $content, $matches );
$attachment_ids = array();
if ( $did_match &&
isset( $matches[1] ) &&
$matches[1] ) {
$attachment_ids = explode( ',', preg_replace( '/\s/', '', $matches[1] ) );
}
$img_data = array();
foreach ( $attachment_ids as $attachment_id ) {
$attachment_id = preg_replace( '/\D/', '', $attachment_id );
$image = wp_get_attachment_image_src( $attachment_id, 'full', false );
$caption = wp_get_attachment_caption( $attachment_id );
$img_data[] = array(
'url' => $image[0],
'caption' => $caption,
);
}
?>
<a href="<?php echo get_permalink();?>" <?php echo ! empty( $attachment_ids ) ? 'class="media-fresco" data-gallery="' . esc_attr( json_encode( $img_data ) ) . '"' : ''; ?>">
<div class="image">
<?php the_post_thumbnail();?>
</div>
<div class="text">
<h5><?php the_title();?></h5>
</div>
</a>
</div>
</div>
<?php
if ( $index == $max_per_row ) : ?>
</div>
<?php
$index = 0;
else :
$index++;
endif;
endwhile;
wp_reset_postdata();
// Ensure that the row closes out
if ( $index < $max_per_row &&
$index > 0 ) : ?>
</div>
<?php endif;
echo do_shortcode( '[facetwp pager="true"]' );
endif; ?>
</div>
</div>
<?php get_footer();