-
Notifications
You must be signed in to change notification settings - Fork 0
/
single.php
148 lines (143 loc) · 5.2 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
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
<?php
/**
* The template for displaying all single posts
*/
get_header();
get_template_part( 'parts/navigation' );
?>
<style>
.main{
font-family: system-ui;
}
.container_blog {
width: 100%;
padding: 2rem 1rem;
margin-right: auto;
margin-left: auto;
box-sizing: border-box;
}
.container_blog_inner{
gap: 5rem;
justify-content: center;
display: flex;
}
.mainpost{
width: 75%;
}
.sidebar{
width: 25%;
}
.sidebar_link{
text-decoration: none;
color: var(--main_colour);
}
.post__title{
color: var(--main_colour);
font-size: 2rem;
}
@media(max-width:1100px){
.container_blog_inner{
flex-direction: column;
}
.mainpost{
width:100%;
}
.sidebar{
width: 100%;
}
}
@media (min-width: 576px) {
.container_blog {
max-width: 540px;
}
}
@media (min-width: 768px) {
.container_blog {
max-width: 720px;
}
}
@media (min-width: 992px) {
.container_blog {
max-width: 900px;
}
}
@media (min-width: 1200px) {
.container_blog {
max-width: 1100px;
}
}
</style>
<main class="main mt-xl-3" role="main">
<div class="container_blog">
<div class="container_blog_inner">
<div class="mainpost">
<?php while ( have_posts() ) : the_post(); ?>
<article <?php post_class(); ?>>
<?php if (has_post_thumbnail()): ?>
<div class="featured-image-wrapper">
<?php the_post_thumbnail('full', ['class' => 'featured-image']); ?>
</div>
<?php endif; ?>
<header class="post__header" role="heading">
<h1 class="post__title"><?php the_title(); ?></h1>
</header>
<p class="post__date pb-1">
Date: <?php echo esc_html(get_the_date('F j, Y'));?>
</p>
<hr>
<div class="post__content">
<?php the_content(); ?>
</div>
</article>
<?php endwhile; ?>
</div>
<div class="sidebar">
<div>
<p class="sidebar-title">Recent Blogs</p>
<?php
// set up the arguments for the query to select the main post
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 5, // Set the number of recent posts to display
'orderby' => 'date',
'order' => 'DESC'
);
// create a new WP_Query instance with the arguments
$query = new WP_Query( $args );
// start the loop
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post();
?>
<div style="border-top: 1px solid #414141;">
<article <?php post_class(); ?>>
<div class="d-flex align-items-center">
<?php if(has_post_thumbnail()): ?>
<div class="img-wrapper_sixpack_sidebar">
<div style="border-radius:.5rem" class="img-wrapper_thumbnail">
<?php the_post_thumbnail( array(40, 40) ); ?>
</div>
</div>
<?php endif; ?>
<header class="post__header px-1" role="heading">
<p class="recent-posts-title">
<a class="sidebar_link bold" href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</p>
</header>
</div>
</article>
</div>
<?php
endwhile;
endif;
// reset the query
wp_reset_postdata();
?>
</div>
</div>
</div>
</div>
</main>
<?php get_footer();?>