-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle-academic.php
92 lines (77 loc) · 3.14 KB
/
single-academic.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
<?php
get_header();
pageBanner();
while(have_posts()) {
the_post();
?>
<div class="container container--narrow page-section">
<div class="generic-content">
<div class="row group">
<div class="one-third">
<?php the_post_thumbnail('academicPortrait') ?>
</div>
<div class="two-thirds">
<?php
$likeCount = new WP_Query(array(
'post_type' => 'like',
'meta_query' => array(
array(
'key' => 'liked_academic_id',
'compare' => '=',
'value' => get_the_ID()
)
)
));
$existStatus = 'no';
if(is_user_logged_in()) {
$existQuery = new WP_Query(array(
'author' => get_current_user_id(),
'post_type' => 'like',
'meta_query' => array(
array(
'key' => 'liked_academic_id',
'compare' => '=',
'value' => get_the_ID()
)
)
));
if ($existQuery->found_posts) {
$existStatus = 'yes';
}
}
?>
<!-- data-exists toggles yes/no depending on whether a post exists from the current user for the current academic -->
<!-- data-academic used to identify which academic is being targeted via $existQuery which sets $existStatus-->
<!-- data-like used when deleting the post to find the id of the like that needs deleting via $existQuery results array -->
<span
class="like-box"
data-exists="<?php echo $existStatus; ?>"
data-academic="<?php the_id(); ?>"
data-like="<?php echo $existQuery->posts[0]->ID; ?>"
>
<i class="fa fa-heart-o" aria-hidden="true"></i>
<i class="fa fa-heart" aria-hidden="true"></i>
<span class="like-count"><?php echo $likeCount->found_posts; ?></span>
</span>
<?php the_content() ?>
</div>
</div>
<?php
$relatedPrograms = get_field('related_program');
if ($relatedPrograms) {
echo '<hr class=section-break">';
echo '<h2 class="headline headline--medium">Subject(s) Taught</h2>';
echo '<ul class="link-list min-list">';
foreach($relatedPrograms as $program) {
?>
<li><a href="<?php echo get_the_permalink($program); ?>"><?php echo get_the_title($program); ?></a></li>
<?php
}
echo '</ul>';
}
?>
</div>
<?php
}
get_footer();
?>