Skip to content

Commit eafd274

Browse files
committed
1 parent c16d71c commit eafd274

File tree

8 files changed

+566
-53
lines changed

8 files changed

+566
-53
lines changed

archive-jetpack-portfolio.php

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,59 @@
11
<?php
2-
get_header(); ?>
2+
get_header();
33

4-
<div id="primary" class="content-area col-md-12 mb-xs-24">
4+
$layout = get_theme_mod( 'projects_layout_view', 'mansonry' );
5+
$layout_class = shapely_get_layout_class();
6+
7+
$item_classes = 'post-snippet col-md-3 col-sm-6 project';
8+
if ( 'mansonry' == $layout ) {
9+
$item_classes .= ' masonry-item';
10+
}
11+
12+
?>
13+
<?php
14+
if ( 'sidebar-left' == $layout_class ) :
15+
get_sidebar();
16+
endif;
17+
?>
18+
<div id="primary" class="content-area col-md-8 mb-xs-24 <?php echo esc_attr( $layout_class ); ?>">
519
<main id="main" class="site-main" role="main">
620

721
<?php
822
if ( have_posts() ) : ?>
923

10-
<header>
11-
<?php
12-
echo ( get_theme_mod( 'portfolio_name' ) != '' ) ? '<h1 class="post-title">' . esc_html( get_theme_mod( 'portfolio_name' ) ) . '</h1>' : '';
13-
echo ( get_theme_mod( 'portfolio_description' ) != '' ) ? '<p>' . esc_html( get_theme_mod( 'portfolio_description' ) ) . '</p>' : '';
14-
?>
15-
</header><!-- .page-header -->
16-
17-
<div class="masonry-loader fixed-center">
18-
<div class="col-sm-12 text-center">
19-
<div class="spinner"></div>
24+
<?php if ( 'mansonry' == $layout ): ?>
25+
<div class="masonry-loader fixed-center">
26+
<div class="col-sm-12 text-center">
27+
<div class="spinner"></div>
28+
</div>
2029
</div>
21-
</div>
22-
<div class="masonry masonryFlyIn">
30+
<?php endif ?>
31+
32+
<div class="<?php echo 'mansonry' == $layout ? 'masonry masonryFlyIn' : '' ?>">
2333
<?php
2434
/* Start the Loop */
2535
while ( have_posts() ) : the_post();
2636
$projects_args = array(
2737
'fields' => 'names',
2838
);
2939
$project_types = wp_get_post_terms( $post->ID, 'jetpack-portfolio-type', $projects_args );
40+
41+
$thumbnail_url = get_the_post_thumbnail_url( get_the_ID(), 'full' );
42+
$item_style = '';
43+
if ( 'mansonry' != $layout ) {
44+
$item_style = 'background-image: url(' . $thumbnail_url . ')';
45+
}
3046
?>
3147

32-
<article id="post-<?php the_ID(); ?>" <?php post_class( 'post-snippet col-md-3 col-sm-6 masonry-item project' ); ?>>
33-
<div class="image-tile inner-title hover-reveal text-center"><?php
48+
<article id="post-<?php the_ID(); ?>" <?php post_class( $item_classes ); ?>>
49+
<div class="image-tile inner-title hover-reveal text-center" style="<?php echo $item_style ?>"><?php
3450
if ( has_post_thumbnail() ) { ?>
3551
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
36-
<?php the_post_thumbnail( 'medium' ); ?>
52+
<?php
53+
if ( 'mansonry' == $layout ){
54+
the_post_thumbnail( 'medium' );
55+
}
56+
?>
3757
<div class="title"><?php
3858
the_title( '<h5 class="mb0">', '</h5>' );
3959
if ( ! empty( $project_types ) ) {
@@ -57,6 +77,10 @@
5777

5878
</main><!-- #main -->
5979
</div><!-- #primary -->
60-
80+
<?php
81+
if ( 'sidebar-right' == $layout_class ) :
82+
get_sidebar();
83+
endif;
84+
?>
6185
<?php
6286
get_footer();

inc/class-shapely-related-posts.php

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,43 @@ public function get_related_posts( $post_id, $number_posts = - 1 ) {
112112
'ignore_sticky_posts' => 0,
113113
'posts_per_page' => $number_posts,
114114
'post__not_in' => array( $post_id ),
115-
// 'meta_key' => '_thumbnail_id',
116115
) );
117116

117+
if ( is_singular( 'jetpack-portfolio' ) ) {
118+
unset( $args['category__in'] );
119+
$args['post_type'] = 'jetpack-portfolio';
120+
121+
$terms_args = array(
122+
'fields' => 'ids',
123+
);
124+
$types = wp_get_object_terms( get_the_ID(), 'jetpack-portfolio-type', $terms_args );
125+
$tags = wp_get_object_terms( get_the_ID(), 'jetpack-portfolio-tag', $terms_args );
126+
127+
$tax_query = array();
128+
129+
if ( ! empty( $types ) ) {
130+
array_push( $tax_query, array(
131+
'taxonomy' => 'jetpack-portfolio-type',
132+
'field' => 'term_id',
133+
'terms' => $types,
134+
));
135+
}
136+
137+
if ( ! empty( $tags ) ) {
138+
array_push( $tax_query, array(
139+
'taxonomy' => 'jetpack-portfolio-tag',
140+
'field' => 'term_id',
141+
'terms' => $tags,
142+
));
143+
}
144+
145+
if ( ! empty( $tax_query ) ) {
146+
$args['tax_query'] = $tax_query;
147+
}
148+
149+
150+
}
151+
118152
$related_postquery = new WP_Query( $args );
119153

120154
// reset post query
@@ -129,6 +163,13 @@ public function get_related_posts( $post_id, $number_posts = - 1 ) {
129163
* @return string HTML markup to display related posts
130164
**/
131165
function output_related_posts() {
166+
167+
if ( is_singular( 'jetpack-portfolio' ) ) {
168+
if ( ! get_theme_mod( 'related_projects_area', true ) ) {
169+
return;
170+
}
171+
}
172+
132173
// Check if related posts should be shown
133174
$related_posts = $this->get_related_posts( get_the_ID(), get_option( 'posts_per_page' ) );
134175

@@ -150,7 +191,11 @@ function output_related_posts() {
150191
* Heading
151192
*/
152193
echo '<div class="col-lg-11 col-sm-10 col-xs-12 shapely-related-posts-title">';
153-
echo '<h3><span>' . esc_html__( 'Related articles ', 'shapely' ) . '</span></h3>';
194+
if ( is_singular( 'jetpack-portfolio' ) ) {
195+
echo '<h3><span>' . esc_html__( 'Related projects', 'shapely' ) . '</span></h3>';
196+
}else{
197+
echo '<h3><span>' . esc_html__( 'Related articles ', 'shapely' ) . '</span></h3>';
198+
}
154199
echo '</div>';
155200

156201
echo '</div><!--/.row-->';

0 commit comments

Comments
 (0)