correct author page

This commit is contained in:
argoexpert press
2025-07-28 22:50:59 +03:00
parent 329fff0696
commit 6228d8ba21
2 changed files with 69 additions and 29 deletions

View File

@@ -5,18 +5,16 @@
<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>';
//$author_id = get_queried_object_id();
$author_id = get_the_author_meta('ID');
$avatar_id = get_user_meta($author_id, 'avatar_attachment_id', true);
if ($avatar_id) {
echo wp_get_attachment_image($avatar_id, 'medium', false, array('class' => 'author-avatar'));
} else {
// Fallback: Gravatar или дефолтное изображение
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>