add author avatar
This commit is contained in:
24
author.php
24
author.php
@@ -1,15 +1,29 @@
|
||||
<?php get_header(); ?>
|
||||
<div class="content-middle articles-wrapper">
|
||||
<?php get_template_part('partials/rubrics-mobile'); ?>
|
||||
|
||||
<div class="section-title desktop">
|
||||
|
||||
<div class="section-title-author">
|
||||
<?php
|
||||
// Получаем ID текущего автора
|
||||
$author_id = get_queried_object_id();
|
||||
|
||||
// Пробуем получить кастомный аватар (из вашего кода)
|
||||
$custom_avatar = get_user_meta($author_id, 'avatar', true);
|
||||
|
||||
// Если аватар есть — выводим его, иначе — стандартный Gravatar
|
||||
if ($custom_avatar) {
|
||||
echo '<div class="author-avatar"><img src="' . esc_url($custom_avatar) . '" alt="' . esc_attr(get_the_author_meta('display_name', $author_id)) . '" width="100" height="100" class="avatar-round" /></div>';
|
||||
} else {
|
||||
echo '<div class="author-avatar">' . get_avatar($author_id, 100, '', '', array('class' => 'avatar-round')) . '</div>';
|
||||
}
|
||||
?>
|
||||
<h1 class="section-title__title"><?= get_the_author(); ?></h1>
|
||||
</div>
|
||||
|
||||
<?php if (!is_paged()) {
|
||||
$author_description = get_the_author_meta('description');
|
||||
if (!empty($author_description)) {
|
||||
echo '<div class="article-item__text">';
|
||||
echo '<div class="author-desc">';
|
||||
echo nl2br(esc_html($author_description));
|
||||
echo '</div>';
|
||||
}
|
||||
@@ -22,7 +36,7 @@
|
||||
'post_type' => 'post',
|
||||
'posts_per_page' => 11,
|
||||
'paged' => $paged,
|
||||
'author' => get_queried_object_id()
|
||||
'author' => $author_id
|
||||
);
|
||||
$query = new WP_Query($args);
|
||||
?>
|
||||
@@ -31,4 +45,4 @@
|
||||
|
||||
<?php custom_pagination(); ?>
|
||||
</div>
|
||||
<?php get_footer(); ?>
|
||||
<?php get_footer(); ?>
|
||||
Reference in New Issue
Block a user