/
template-portfolio-grid.php
70 lines (49 loc) · 2.04 KB
/
template-portfolio-grid.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
<?php
/*
T-MMM-emplate Name: Grid Portfolio
*/
gp_add_html_class( 'horizontal-page layout-portfolio-grid' );
get_header();
if ( is_page() ) {
gp_query_portfolio();
}
if ( have_posts() ) :
$grid_portfolio = new GridPortfolio( get_the_ID() );
?>
<div id="main" class="site">
<div class="portfolio-grid" data-columns="<?php echo $grid_portfolio->get_grid_column_count(); ?>" data-rows="<?php echo $grid_portfolio->get_grid_row_count(); ?>"><?php
while ( have_posts() ) :
the_post();
$project = new PortfolioProject( get_the_ID() );
$featured = $project->get_featured_media();
if ( ! $featured ) continue; // We have no media on this project, nothing to show.
if ( $featured->is_image() ) {
$image = $featured->get_image_data( 'gp-thumbnail' );
$image = $image ? $image['src'] : '';
} else {
$image = $featured->get_video_thumbnail( 'gp-thumbnail' );
if ( ! $image ) {
$image = array( 'src' => get_template_directory_uri() . '/images/no-portfolio-thumbnail.png' );
}
$image = $image['src'];
}
?>
<article class="grid-project">
<a href="<?php the_permalink(); ?>" class="preview" style="background-image: url(<?php echo esc_url( $image ); ?>);">
<span class="hover-box">
<span class="inner"><?php
if ( $project->meta_subtitle ) : ?>
<i><?php echo $project->meta_subtitle; ?></i><?php
endif; ?>
<b><?php the_title(); ?></b>
</span>
</span>
</a>
</article><?php
endwhile; ?>
</div>
</div>
<?php
endif;
wp_reset_query();
get_footer();