Site logo

[Support request] Display Author’s social links on Author profile page

Home Forums Support [Support request] Display Author’s social links on Author profile page

Home Forums Support Display Author’s social links on Author profile page

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1809930
    JC

    Hello,

    I have GP premium and Yoast SEO premium and what I am trying to do is display the Author’s social links on the profile page (Author Archive page).

    What I have done is create a Hook;
    ELEMENTS – New – Hook
    Hook = generate_after_arhive_title
    Display Urle: Arhcive Pages

    So my placeholder text shows and then I realised I have no idea how to display the fields there and it’s always on themes I use but this is GP so I probably have to use some PHP wit CSS for it but no clue how to do it. Any help would be appreciated 😉

    #1810295
    David
    Staff
    Customer Support

    Hi there,

    if the social links are added by Yoast then you would need some code.
    I found this article that provides a shortcode PHP Function:

    https://www.billerickson.net/code/displaying-social-links-from-yoast-seo/

    With that function added to your site – ( this article explains adding PHP ) you can add the [social_links] shortcode in your element.

    #1810310
    JC

    Hi David, good to read you again and thank you for the quick response.

    I did find that article but it only includes for the site social links opposed to the social links on the author profile.

    So when we complete author profiles and add Facebook, Twitter, Linkedin, Website etc, to have that display from the Author’s account on his profile page.

    #1810388
    David
    Staff
    Customer Support

    I discovered they store the values in the author meta… so you ‘should’ be able to do this:

    function get_yoast_socials() {
        // Create HTML variable
        $html = '';
        // Get author ID
        $author = get_queried_object();
        // Get yoast meta values for social links
        $twitter = get_the_author_meta( 'twitter', $author->ID );
        $facebook = get_the_author_meta( 'facebook', $author->ID );
        // Append HTML with social links
        $html = '<a class="social-link" href="https://twitter.com/' . $twitter .'" rel="nofollow" target="_blank">Twitter</a>';
        $html .= '<a class="social-link" href="'. $facebook .'" rel="nofollow" target="_blank">Facebook</a>';
    
        return $html;
    }
    
    add_shortcode('social_links', 'get_yoast_socials');
    #1810389
    JC

    thank you David I am going to give that a go and I will let you know and also try find the rest of the social accounts and share the final version, thank you sooo much!

    #1810741
    David
    Staff
    Customer Support

    You’re welcome

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