/
template-portfolio.php
103 lines (77 loc) · 3.9 KB
/
template-portfolio.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
<?php
/*
T-MMM-emplate Name: Horizontal Portfolio
*/
gp_add_html_class( 'horizontal-page' );
get_header();
?>
<div id="main" class="site site-with-sidebar">
<div id="content" class="site-content">
<div class="portfolio-list horizontal-content"><?php
if ( is_page() ) {
/**
* We are on index page.
* Let's modify main loop to gp_portfolio post type.
*
* If is_page() is false, then we are on taxonomy-gp-project-type.php
* template, so our loop is already correct.
*/
gp_query_portfolio();
}
if ( have_posts() ) :
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.
$attr['class'] = 'horizontal-item project';
if ( $featured->is_image() ) {
$image = $featured->get_image_data( 'gp-max' );
} else {
$image = $featured->get_video_thumbnail( 'gp-max' );
}
if ( ! $image ) {
$image = array( 'src' => get_template_directory_uri() . '/images/no-portfolio-thumbnail.png',
'width' => 1920,
'height' => 1280 );
}
?>
<article <?php echo it_array_to_attributes( $attr ); ?>>
<div class="preview">
<img class="featured-image" src="<?php echo esc_url( $image['src'] ); ?>" width="<?php echo esc_attr( $image['width'] ); ?>" height="<?php echo esc_attr( $image['height'] ); ?>" alt="<?php echo esc_attr( get_the_title() ); ?>">
<div class="hover-box">
<div class="hover-box-contents"><?php
if ( $project->meta_subtitle ) : ?>
<h3 class="subtitle"><?php echo $project->meta_subtitle; ?></h3><?php
endif; ?>
<h2><?php the_title(); ?></h2>
<div class="decoration"></div>
<?php if ( $post->post_excerpt ) : ?>
<div class="excerpt"><?php the_excerpt(); ?></div>
<?php endif; ?>
<div class="wrap-button">
<a href="<?php echo get_permalink( get_the_ID() ); ?>" class="button"><?php _e( 'View Work', 'gp' ); ?></a>
</div>
</div>
</div>
</div>
<section class="info">
<h2 class="entry-title"><a href="<?php echo get_permalink( get_the_ID() ); ?>"><?php the_title(); ?></a></h2><?php
if ( $tags = $project->get_tags() ) : ?>
<div class="entry-tags"><?php
foreach ( $tags as $tag ) : ?>
<a href="<?php echo esc_url( get_term_link( $tag ) ); ?>"><b class="hash">#</b><?php echo $tag->name; ?></a><?php
endforeach; ?>
</div><?php
endif; ?>
</section>
</article><?php
endwhile;
endif; ?>
</div>
</div><?php
wp_reset_query();
get_sidebar( 'portfolio' );
?>
</div>
<?php
get_footer();