Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Author Archive displays wrong name when using multiple authors

  • Hey there!

    I’m working on a WordPressPage using GeneratePress. We want to have the option, to assign multiple authors to one post. For this we are using the plugin “PublishPress Authors”. When viewing the author archive, the displayed name is sometimes wrong.

    This happens, when the newest post is one with multiple authors and the first author is different to the archives author.

    Screenshot: https://postimg.cc/SjcK8RgT

    In this example, I’ve opened Henrik’s author page, but the newest blog has a different first author. We only have the issue with the authors name. The authors avatar and biography are correct.

    Does anybody know how to fix this?

  • Hi there,

    Does the issue persist if you switch the theme to the twenty twenty themes?

    Let me know πŸ™‚

  • Hi, thanks for your reply.
    Because it is an active client-project, I created an exact copy on a different server.
    After switching to the twenty-twenty-theme, the problem seams to be solved. The theme apparently does not support to show both authors, but the author-archive displays the correct name.
    In the private information, I added the URL for the copy on my private server.

  • Can I see the client site with GP theme as well so I can compare?

  • Unfortunately I can’t grant access to this site, but I made a copy on my personal VM. I added the details in the private information. Thanks a lot!

  • So in twenty-twenty themes, it does not work on single posts, but works on the author archive, in GP, it’s the opposite, right?

    Try this method:

    1. Add this PHP code to create a shortcode for the author archive title and remove the original author archive title .

    function custom_author_shortcode() {
        ob_start();
        $author_id = get_queried_object_id(); // Get the author ID for the current archive
        $author_name = get_the_author_meta('display_name', $author_id); // Get the author's display name
        
        $title = sprintf(
                '%1$s<span class="vcard">%2$s</span>',
                get_avatar(get_the_author_meta('ID'), 50),
                $author_name
            );
    	echo '<header class="page-header" aria-label="Page"><h1 class="page-title">'.$title.'</h1></header>';
    	return ob_get_clean();
    }
    add_shortcode( 'custom_author', 'custom_author_shortcode' );
    
    //remove original author archive title
    add_action('wp', function() {
        remove_action('generate_archive_title', 'generate_archive_title', 10);
    });

    2. Add this shortcode [custom_author] to a hook element, tick the execute shortcode box, set the location to author archive, and set the hook to generate_before_main_content.

    Let me know if this helps!

  • Thanks a lot! The fix worked! I just added the authors biograhpy to the code, now it works, as we want it to.

    We have got another issue regarding GeneratePress with the PublishPress Authors Plugin. We activated the authors box at the end of every post. It basicly works fine, but we always have a “by” above both boxes, which we want to get rid of.

    Screenshot: https://postimg.cc/CR2mCg0c

    I tested a couple of other themes including Twenty-Twenty and the issue is just happening with GeneratePress. Can I keep this topic open for this issue or should I open a new topic?

    I already tried to find the source of this line, but were not succesfull yet.

  • The by is from GP, I tested it on my site, but even after adding a filter to remove the by, the by still appears in the plugin’s author box, it seems like the plugin is pulling the data before my code fires.

    Can you check with the plugin’s support if they have a way to remove the by?

  • I found help in the plugin’s support forum. It’s not the perfect solution, but a workaround. As I am not the most experienced coder, there probably is an easier and cleaner way to do this, but maybe it still can help others, facing a similar problem. πŸ™‚

    Disclaimer: I use a german version of WordPress and GeneratePress, so I might translate some menu-options not 100% correctly.

    First: the PublishPress-Authors plugin is somehow changing the way how authors meta-data is stored. At least that’s what I think, because as soon as I activate the plugin, GeneratePress does not show any author-information on the archives and single post pages anymore.

    For that I used elements and the hook generate_post_author_output containing the shortcode [publishpress_authors_data field="display_name" seperator=",&nbsp;"].

    The “by” before the author-boxes is added by GeneratePress. You deactive it in the customizer in "layout" -> "blog" -> "single". There you have to deactivate "show post-author". The only problem: this also removes the post’s author at the start of the post. With the following workaround you will need to deactive this option for archives as well.

    My workaround is adding a hook at generate_post_date_output containing [post_date] von [publishpress_authors_data field="display_name" seperator=",&nbsp;"].

    The shortcode [post_date] is created with this code:

    function shortcode_post_published_date(){
     return get_the_date();
    }
    add_shortcode( 'post_date', 'shortcode_post_published_date' );
  • Glad you figured out a workaround πŸ™‚ Good job!

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.