-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsingle.php
123 lines (91 loc) · 2.64 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
get_header();
while (have_posts()): the_post();
# Vars
$title = get_the_title();
$content = get_content();
# Featured Image?
if ( has_post_thumbnail() ) {
$id = get_post_thumbnail_id();
$bg = get_post_thumbnail_url( 'full' );
?>
<section class="block block__banner--single" <?php echo $bg; ?>>
<div class="ctn">
<div class="block__main">
<h1 class="banner__title"><?php echo $title; ?></h1>
</div>
</div>
</section>
<?php } ?>
<section class="block block__single">
<div class="ctn">
<?php
# If there is not a featured image, put the title in the header.
if ( !has_post_thumbnail() ) {
$html = '';
$html .= '<div class="block__header">';
$html .= '<h1 class="block__title">' . $title . '</h1>';
$html .= '</div>';
echo $html;
}
?>
<div class="block__main">
<?php
# Content Section
echo '<article class="cnt">';
echo $content;
# If Share Bar is Selected?
get_template_part( 'inc/loop', 'share' );
echo '</article>';
# If Recent Posts Sidebar is Selected?
echo '<aside class="single__sidebar">';
# Get Current Post Type
$type = get_post_type();
# Run Query for Post Type
$args = array( 'post_type' => $type, 'posts_per_page' => 3 );
$loop = new WP_Query( $args );
if ( $loop->have_posts() ):
$html = '';
# Sidebar Title
$html .= '<h3 class="single__sidebar-title">Recent ' . $type . 's</h3>';
$html .= '<ul class="recent-posts">';
# Loop
while ( $loop->have_posts() ): $loop->the_post();
$title = get_the_title();
$link = get_permalink();
$html .= '<li class="recent-post-item">' . '<a href="' . $link . '">' . $title . '</a></li>';
endwhile;
$html .= '<ul>';
echo $html;
endif;
echo '</aside>';
# If Recent Posts Slider is Selected
$html = '';
$html .= '<div class="recent-posts__container">';
$html .= '<div class="recent-posts__slider" id="recent-posts__slider">';
# Post Type
$type = get_post_type();
# Loop
$loop = new WP_Query( array( 'post_type' => $type, 'posts_per_page' => 20 ) );
while ( $loop->have_posts() ): $loop->the_post();
# Vars
$title = get_the_title();
$link = get_permalink();
$bg = get_post_thumbnail_url( 'full' );
# Slider Item
$html .= '<div class="recent-posts__slider-item" ' . $bg . '>';
$html .= '<h3 class="recent-posts__slider-item-title">' . $title . '</h3>';
$html .= '<a href="' . $link . '"></a>';
$html .= '</div>';
endwhile;
$html .= '</div>';
$html .= '</div>';
echo $html;
?>
</div>
</div>
</section>
<?php
endwhile;
get_footer();
?>