correct author page
This commit is contained in:
18
author.php
18
author.php
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user