-
Notifications
You must be signed in to change notification settings - Fork 0
/
single.php
executable file
·96 lines (92 loc) · 3.25 KB
/
single.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
<?php get_header(); ?>
<?php the_post(); ?>
<article class="self">
<h1 class="title"><?php the_title(); ?></h1>
<div class="content">
<?php the_content(); ?>
</div>
<div class="bottom">
<?php
if(get_the_tag_list()) {
echo get_the_tag_list('<div class="tags secondary">tags: ',', ','</div>');
} ?>
</div>
</article>
<section class="row">
<!-- display tag related references -->
<?php
$already_displayed_IDs = array($post->ID);
//for use in the loop, list 9 post titles related to first tag on current post
$tags = wp_get_post_tags($post->ID);
if ($tags) {
$first_tag = $tags[0]->term_id;
$args_related = array(
'tag__in' => array($first_tag),
'post__not_in' => $already_displayed_IDs,
'posts_per_page' => 5,
'caller_get_posts' => 1
);
$related = new WP_Query($args_related);
?>
<?php if ( $related->have_posts() ) : ?>
<?php while ($related->have_posts()) : $related->the_post(); array_push($already_displayed_IDs, get_the_ID()); ?>
<article class="col-lg-4 col-md-6 col-sm-12 related">
<a href="<?php the_permalink(); ?>"
class="primary"
title="<?php printf( __('Go to %s', 'cargofolio'), the_title_attribute('echo=0') ); ?>"
rel="bookmark">
<?php if ( has_post_thumbnail() ) {
echo get_the_post_thumbnail( null, 'cargofolio-thumbnail-home', array( 'width' => 'alignleft' ) );
} else { ?>
<img src="data:image/gif;base64,R0lGODlhAQABAIABAAJ12AAAACwAAAAAAQABAAACAkQBADs=" width="200" height="135" class="" alt="">
<?php
} ?>
<div class="project-name"><?php the_title(); ?></div>
</a>
<div class="tags secondary">
<?php if(get_the_tag_list()) {
echo get_the_tag_list('',', ');
} ?>
</div>
</article>
<?php endwhile; ?>
<?php endif;
wp_reset_query();
} // if tags
?>
<!-- display other references -->
<?php
$args_other = array(
'post__not_in' => $already_displayed_IDs,
'posts_per_page' => 12 - count($already_displayed_IDs),
'caller_get_posts' => 1
);
$other = new WP_Query($args_other);
?>
<?php if ( $other->have_posts() ) : ?>
<?php while ($other->have_posts()) : $other->the_post(); array_push ($already_displayed_IDs, get_the_ID()); ?>
<article class="col-lg-4 col-md-6 col-sm-12 related">
<a href="<?php the_permalink(); ?>"
class="primary"
title="<?php printf( __('Go to %s', 'cargofolio'), the_title_attribute('echo=0') ); ?>"
rel="bookmark">
<?php if ( has_post_thumbnail() ) {
echo get_the_post_thumbnail( null, 'cargofolio-thumbnail-home', array( 'width' => 'alignleft' ) );
} else { ?>
<img src="data:image/gif;base64,R0lGODlhAQABAIABAAJ12AAAACwAAAAAAQABAAACAkQBADs=" width="200" height="135" class="" alt="">
<?php
} ?>
<div class="project-name"><?php the_title(); ?></div>
</a>
<div class="tags secondary">
<?php if(get_the_tag_list()) {
echo get_the_tag_list('',', ');
} ?>
</div>
</article>
<?php endwhile; ?>
<?php endif;
wp_reset_query();
?>
</section>
<?php get_footer(); ?>