- This topic has 5 replies, 2 voices, and was last updated 4 years, 4 months ago by
David.
-
AuthorPosts
-
June 4, 2021 at 5:58 am #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 PagesSo 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 😉
June 4, 2021 at 7:57 am #1810295David
StaffCustomer SupportHi 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.June 4, 2021 at 8:06 am #1810310JC
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.
June 4, 2021 at 9:13 am #1810388David
StaffCustomer SupportI 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');June 4, 2021 at 9:14 am #1810389JC
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!
June 4, 2021 at 3:45 pm #1810741David
StaffCustomer SupportYou’re welcome
-
AuthorPosts
- You must be logged in to reply to this topic.