-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle.php
More file actions
208 lines (155 loc) · 5.8 KB
/
single.php
File metadata and controls
208 lines (155 loc) · 5.8 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?php
/**
* The template for displaying all single posts
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* @package Milors
*/
get_header();
global $post;
$author_id = $post->post_author;
$header_excerpt = apply_filters('the_excerpt', get_the_excerpt($post));
$sidebar = get_post_meta( get_the_ID(), '_milors_sidebar', true );
$headerStyle = get_post_meta( get_the_ID(), '_milors_single_post_header', true );
?>
<?php if ($headerStyle == 'bigimgwithtitleHeader') : ?>
<div class="article-style-four mb-5">
<div class="article-header article-header-img-overlay">
<?php
$img = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'large-height-fixed', false, '' );
if ( $img != '' ) :
?>
<div class="img-post-thumb img-fluid mx-auto d-block" style="background-image: url('<?php echo esc_url($img[0]); ?>')"></div>
<div class="entry-content">
<span class="post-category">
<?php the_category() ?>
</span>
<h1 class="entry-title pt-1"><?php the_title(); ?></h1>
<div class="entry-meta">
<span class="author vcard">
<span>By</span><?php echo nl2br(get_the_author_meta('display_name', $author_id)); ?>
</span>
<span class="posted-on line">
<span>On</span><time class="entry-date published"
datetime="<?php the_time("M j, Y");?>"><?php the_time("M j, Y");?></time>
</span>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php if ( $sidebar == 'no-sidebar' ) : ?>
<div id="primary" class="no-sidebar container py-md-5 py-lg-5">
<?php else : ?>
<div id="primary" class="container py-md-5 py-lg-5">
<?php endif; ?>
<?php if ($headerStyle == 'bigimgHeader') : ?>
<div class="post-media post-image mb-5">
<?php $img = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'large-height-fixed', false, '' ); ?>
<img src="<?php echo esc_url($img[0]); ?>" alt="<?php the_title_attribute(); ?>"
class="img-fluid img-fluid mx-auto d-block">
</div>
<?php elseif ($headerStyle == 'leftHeader') : ?>
<div class="article-style-three pt-2 pb-5 mb-5">
<div class="wrap no-gutters row">
<div class="d-flex align-content-center flex-wrap col-md-5 col-sm-12 col-12 py-5 py-md-0 py-lg-0 py-xl-0 pr-5">
<h1 class="entry-title"><?php the_title(); ?></h1>
<span class="tagging line"><?php the_category(); ?></span>
<?php echo $header_excerpt; ?>
<div class="post-author">
<div class="post-author-avatar">
<?php
$user_id = get_the_author_meta('ID', $author_id);
echo get_avatar( $user_id, 35 );
?>
</div>
<div class="post-author-name">
<a
href="<?php echo get_author_posts_url( get_the_author_meta( 'ID', $author_id ), get_the_author_meta( 'user_nicename', $author_id ) ); ?>">
<?php echo nl2br(get_the_author_meta('display_name', $author_id)); ?>
</a>
<br>
<time class="entry-date" datetime="<?php the_time("M j, Y");?>"><?php the_time("M j, Y");?></time>
</div>
</div>
</div>
<div class="col-md-7 col-sm-12 col-12">
<?php $img = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'fullsize', false, '' ); ?>
<img src="<?php echo esc_url($img[0]); ?>" class="img-fluid" alt="<?php the_title_attribute(); ?>">
</div>
</div>
</div>
<?php endif; ?>
<div class="row">
<?php if ( $sidebar === 'rightSidebar' ) { ?>
<div class="col-md-8 col-lg-8 col-xl-8 col-sm-12 pr-5">
<?php
while ( have_posts() ) :
the_post();
get_template_part( 'template-parts/content', get_post_type() );
milors_author_bio();
// calling related post function
milors_related_post(array(
'taxonomy' => 'category',
'limit' => 6
));
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile; // End of the loop.
?>
</div>
<div class="col-md-4 col-lg-4 col-xl-4 col-sm-12 widgets-no-padding">
<?php get_sidebar(); ?>
</div>
<?php } elseif ( $sidebar === 'leftSidebar' ) { ?>
<div class="col-md-4 col-lg-4 col-xl-4 col-sm-12">
<?php get_sidebar(); ?>
</div>
<div class="col-md-8 col-lg-8 col-xl-8 col-sm-12 pl-5">
<?php
while ( have_posts() ) :
the_post();
get_template_part( 'template-parts/content', get_post_type() );
milors_author_bio();
milors_related_post(array(
'taxonomy' => 'post_tag',
'limit' => 3
));
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile; // End of the loop.
?>
</div>
<?php } else { // No Sidebar?>
<div class="col-12 col-md-12 col-sm-12 no-sidebar">
<?php
while ( have_posts() ) :
the_post();
get_template_part( 'template-parts/content', get_post_type() );
?>
<div class="no-sidebar single-post">
<?php
milors_author_bio();
milors_related_post(array(
'taxonomy' => 'category',
'limit' => 6
));
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
?>
</div>
<?php endwhile; // End of the loop.
?>
</div>
<?php } ?>
</div>
</div><!-- #primary -->
<?php get_footer(); ?>