Make Yoast SEO’s Social Contact Methods Accessible on the Front-End of WordPress

The Yoast SEO plugin registers some helpful Social Media contact methods on a WordPress User Profile that are available for users to add information for Google+, Twitter, and Facebook.

You can access the values set for each user on the front-end of your WordPress site using the get_the_author_meta() function.

However, when creating an Author template in a theme or for your project, you’ll possibly never know exactly what meta you should be looking for to output. Using the “get_the_author_meta()” approach assumes that we’ll know the exact fields to display even though an unlimited number of options can be added via other plugins or another theme.

In this scenario, WordPress has a very helpful function called “wp_get_user_contact_methods()” which will list all the possible contact methods available on the site and allow you to query the user for each available method.

So, why can’t we do that with the Yoast contact methods?

If you’re using Yoast and have added information to those fields on your profile, try running the “wp_get_user_contact_methods()” and see what gets returned on your front-end template.

They’re not there.

The reason is that Yoast runs the filter for these only within the admin of your site. So, you can see them within the profile but not listed as options on the front-end there.

The below snippet will re-register the Yoast contact methods and make them available from anywhere in your site.

Exit mobile version