• Resolved dukearmi

    (@dukearmi)


    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="%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="%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="%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.

    • This topic was modified 7 months ago by dukearmi.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hi Duke!

    Where did you use to see the avatar appear, and where would you like it to appear again?

    I cannot find that code reflected on any of your website’s pages. Where did you install that code, or did you change it after you created this topic?

    As an aside, neither The SEO Framework nor Rank Math should affect your site’s content, including the entry meta, so I don’t think it concerns the SEO plugins.

    Thread Starter dukearmi

    (@dukearmi)

    Hi Sybre,

    I was seeing the author name and avatar in the white box under the page title (dispalying default gravatar now). I mean the code is a PHP snippet in WP Code. This worked when I had Rank Math. I just tested and it worked when I went back to Rank Math but disappeared when I activated your plugin.

    • This reply was modified 6 months, 4 weeks ago by dukearmi.
    Thread Starter dukearmi

    (@dukearmi)

    Actually I just fixed i and now it’s even better than before. It was the PHP not retrieving the author name the right way.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Issue with Author Name and Avatar after Switching from Rank Math’ is closed to new replies.