-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauthor.php
257 lines (247 loc) · 7.67 KB
/
author.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
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<?php
// Template name: author-admin
?>
<!-- Include Header -->
<?php get_header(); ?>
<!-- === MODAL INSURANCE TYPES === -->
<?php echo do_shortcode('[merlin-dialler-modal-list]'); ?>
<!-- === FORM === -->
<?php echo do_shortcode('[merlin-dialler-form]'); ?>
<!-- Section Breadcrumbs -->
<section class="s-breadcrumbs">
<div class="container">
<ul>
<li>
<a href="<?php echo get_home_url(); ?>" aria-label="home page">
<i class="fa-solid fa-house"></i>
</a>
</li>
<?php
// Get the author object
$author = get_queried_object();
// Get the author archive URL
$author_archive_url = get_author_posts_url($author->ID);
?>
<li>
<a href="<?php echo esc_url($author_archive_url); ?>" aria-label="current page">
<?php echo $author->display_name; ?>
</a>
</li>
</ul>
<a href="<?php echo get_home_url(); ?>" class="back" aria-label="return page">
<i class="fa-solid fa-chevron-left"></i>
Go Back to Home
</a>
</div>
</section>
<!-- Section Author -->
<section class="s-author">
<div class="container">
<img src="<?php echo get_template_directory_uri() ?>/assets/bg/ellipse.png" alt="" class="s-author-image">
<div class="s-author-right">
<h1>
<?php echo get_the_author(); ?>
</h1>
<span>
Web Developer
</span>
<ul>
<li>
<a href="">
<i class="fa-brands fa-square-twitter"></i>
</a>
</li>
<li>
<a href="">
<i class="fa-brands fa-square-facebook"></i>
</a>
</li>
<li>
<a href="">
<i class="fa-brands fa-linkedin"></i>
</a>
</li>
<li>
<a href="">
<i class="fa-solid fa-up-right-from-square"></i>
</a>
</li>
</ul>
<p>
<?php
// Get the biographical information of the author for the current post
$author_bio = get_the_author_meta('description');
// Display the biographical information
if (!empty($author_bio)) {
echo 'Biographical Info: ' . esc_html($author_bio);
} else {
echo 'No biographical information available.';
}
?>
</p>
</div>
</div>
</section>
<!-- Section Navbar -->
<section class="s-author-navbar">
<div class="container">
<h2>All Stories by Chris Lear</h2>
<!-- Mobile Configuration -->
<div class="select-custom">
<!-- item selected -->
<button class="item-selected js-open-select-custom">
<span>Other Authors</span>
</button>
<!-- Dropdown List -->
<ul class="dropdown-select" id="dropdown-select">
<?php
// Query WordPress users
$users = get_users();
// Check if there are users
if (!empty($users)) {
foreach ($users as $user) {
$author_name = $user->display_name;
$author_id = $user->ID;
$author_bio = get_the_author_meta('description', $author_id);
echo '<li>';
echo '<a href="' . get_author_posts_url($author_id) . '">';
echo '<p>';
echo esc_html($author_name);
echo '</p>';
echo '</a>';
echo '</li>';
}
} else {
echo 'No authors found.';
}
?>
</ul>
</div>
</div>
</section>
<!-- Section Author Posts -->
<section class="s-author-posts">
<div class="container">
<?php
$author_name = 'admin-onesure'; // Replace with the specific author name you want to filter by
if ($tag) {
$args = array(
'post_type' => 'post',
'order' => 'DESC',
'author_name' => $author_name, // Add author name parameter
);
$the_query = new WP_Query($args);
}
?>
<?php if (isset($the_query) && $the_query->have_posts()):
while ($the_query->have_posts()):
$the_query->the_post(); ?>
<a href="<?php the_permalink(); ?>" class="card-author">
<div class="image">
<?php the_post_thumbnail(); ?>
</div>
<div class="info">
<ul class="info-list">
<li>
<span>
<?php echo get_the_author_meta('display_name'); ?>
</span>
</li>
<li>
<span>•</span>
</li>
<li>
<span>
<?php echo get_the_date('j, F'); ?>
</span>
</li>
</ul>
<h6>
<?php
$the_title = get_the_title(); // get the title of the post
$char_limit = 40; // Change this value to your desired character limit
if (strlen($the_title) > $char_limit) {
$trimmed_the_title = substr($the_title, 0, $char_limit) . '...';
echo $trimmed_the_title;
} else {
echo $the_title;
}
?>
</h6>
<p>
<?php
$description = get_field('description_post_general');
$char_limit = 90; // Change this value to your desired character limit
if (strlen($description) > $char_limit) {
$trimmed_description = substr($description, 0, $char_limit) . '...';
echo $trimmed_description;
} else {
echo $description;
}
?>
</p>
</div>
</a>
<?php endwhile; endif; ?>
</div>
</section>
<!-- Other Blog Posts -->
<section class="s-template-support" id="section-other-blog-posts">
<div class="container">
<div class="s-template-support-title">
<h2>Other Blog Posts</h2>
</div>
<div class="s-template-support-content">
<?php
$tag = get_term_by('slug', 'featured', 'post_tag'); // Get the tag object by slug
if ($tag) {
$args = array(
'post_type' => 'post',
'order' => 'DESC',
'tag__in' => $tag->term_id, // Use tag ID in 'tag__in' parameter
);
$the_query = new WP_Query($args);
}
?>
<?php if (isset($the_query) && $the_query->have_posts()):
while ($the_query->have_posts()):
$the_query->the_post(); ?>
<!-- Card post SM -->
<a href="<?php the_permalink(); ?>" class="card-blog-post-xs">
<div class="image">
<!-- WordPress image de destaque -->
<?php the_post_thumbnail(); ?>
</div>
<div class="info">
<h6>
<?php
$the_title = get_the_title(); // get the title of the post
$char_limit = 40; // Change this value to your desired character limit
if (strlen($the_title) > $char_limit) {
$trimmed_the_title = substr($the_title, 0, $char_limit) . '...';
echo $trimmed_the_title;
} else {
echo $the_title;
}
?>
</h6>
<p>
<?php
$description = get_field('description_post_general');
$char_limit = 51; // Change this value to your desired character limit
if (strlen($description) > $char_limit) {
$trimmed_description = substr($description, 0, $char_limit) . '...';
echo $trimmed_description;
} else {
echo $description;
}
?>
</p>
</div>
</a>
<?php endwhile; endif; ?>
</div>
</div>
</section>
<!-- Include Footer -->
<?php get_footer(); ?>