Hello there,
I just switched to your pluging fro Rank Math. I like it so far, but the entry meta is a little messed up now. I use a custom PHP function to display it:
<?php if (is_single()) : ?>
<div class="entry-meta">
<?php
$author_id = get_the_author_meta('ID');
$user_nicename = get_the_author_meta('user_nicename');
$avatar_filename = sanitize_file_name($user_nicename) . '.webp';
$upload_dir = wp_upload_dir(null, false);
$avatar_path = $upload_dir['basedir'] . '/avatars/' . $avatar_filename;
$avatar_url = $upload_dir['baseurl'] . '/avatars/' . $avatar_filename;// Check if the local avatar file exists, otherwise use default avatar
$avatar_html = file_exists($avatar_path)
? sprintf('<img src="https://projectdmc.org/support/topic/issue-with-author-name-and-avatar-after-switching-from-rank-math/%s" alt="Author Avatar" width="96" height="96">', esc_url($avatar_url))
: get_avatar($author_id, 48);
printf(
'<div class="author-wrap">
<span class="author-label">Written by</span>
<a href="https://projectdmc.org/support/topic/issue-with-author-name-and-avatar-after-switching-from-rank-math/%1$s" title="%2$s" rel="author">
<span class="author-name" itemprop="name">%3$s</span>
</a>
</div>
<div class="author vcard">%4$s</div>',
esc_url(get_author_posts_url($author_id)),
esc_attr(sprintf(__('View all posts by %s', 'generatepress'), get_the_author())),
esc_html(get_the_author()),
$avatar_html
);
?>
<?php
$time_string = '<span class="date-label">Published on</span><time class="entry-date published" datetime="https://projectdmc.org/support/topic/issue-with-author-name-and-avatar-after-switching-from-rank-math/%1$s" itemprop="datePublished">%2$s</time>';
if ( get_the_date() !== get_the_modified_date() ) {
$time_string = '<span class="date-label">Updated on</span><time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">%4$s</time>';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
echo sprintf( '<span class="posted-on">%s</span> ', $time_string );
?>
</div>
<?php endif; ?>
</div>
</div>
<?php
});
}
}
And this code worked just fine and showed the author name and local avatar with Rank Math. It’s showing no name and the default gravatar with SEO Framework, for some reason.
I’d appreciate your help with this.
The page I need help with: [log in to see the link]