[Resolved] Change URL Author Link

Home Forums Support [Resolved] Change URL Author Link

Home Forums Support Change URL Author Link

  • This topic has 4 replies, 2 voices, and was last updated 1 year ago by Leo.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1480617
    Alessandro

    Hi i just want to change the author url showed in post page.

    and I followed these instructions:
    https://docs.generatepress.com/article/generate_post_author_output/

    insert this code in the function.php:

    add_filter( 'generate_post_author_output', function( $output ) {    
        return '<a href="MY CUSTOM URL">My Name</a>';
    } );

    In the theme it is invoked in Elements > Post Hero:
    {{post_author}}

    Why don’t work?
    Thank you

    #1480859
    Leo
    Staff
    Customer Support

    Hi there,

    If it’s in the page hero then you’d need this filter instead:
    https://docs.generatepress.com/article/generate_page_hero_post_author/

    Let me know if this helps πŸ™‚

    #1484276
    Alessandro

    Hi,
    have mod but don’t work:

    
    add_filter( 'generate_page_hero_post_author', function() {
        global $post;
        $author_id = $post->post_author;
    
        return sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><a class="url fn n" href="https://www.nomesito.it/author/alessandro/" title="Scopri chi sono" rel="author" itemprop="url"><span class="author-name" itemprop="name">Alessandro</span></a></span>',
            esc_html( get_the_author_meta( 'display_name', $author_id ) )
        );
    } );
    
    #1484304
    Alessandro

    Excuse me πŸ™‚
    I solved:

    add_filter( 'generate_page_hero_post_author', function( $output ) {    
        return '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><a class="url fn n" href="myurl" title="Scopri chi sono" rel="author" itemprop="url"><span class="author-name" itemprop="name">Alessandro</span></a></span>';
    } );
    #1485347
    Leo
    Staff
    Customer Support
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.