Social Links with Yoast

The below code is taken from here, and modified.

<?php if ( function_exists( 'ea_social_links' ) ) echo ea_social_links(); ?>

<?php 
/**
 * Social Links
 * Uses Social URLs specified in Yoast SEO. See SEO > Social
 *
 */
function ea_social_links() {
	$svg_social = '/components/svg-icons/icons/social/';  
	$options = array(
		'facebook' 		=> array(
			'key' 		=> 'facebook_site',
			'icon' 		=> twentytwenty_the_theme_svg( 'facebook', 'social' ),
		),
		'twitter' 		=> array(
			'key' 		=> 'twitter_site',
			'prepend' 	=> 'https://twitter.com/',
			'icon' 		=> twentytwenty_the_theme_svg( 'twitter', 'social' ),
		),
		'instagram' 	=> array(
			'key' 		=> 'instagram_url',
			'icon' 		=> twentytwenty_the_theme_svg( 'instagram', 'social' ),
		),
		'linkedin' 		=> array(
			'key' 		=> 'linkedin_url',
			'icon' 		=> twentytwenty_the_theme_svg( 'linkedin', 'social' ),
		),
		'myspace' 		=> array(
			'key' 		=> 'myspace_url',
			'icon' 		=> twentytwenty_the_theme_svg( 'myspace', 'social' ),
		),
		'pinterest' 	=> array(
			'key' 		=> 'pinterest_url',
			'icon' 		=> twentytwenty_the_theme_svg( 'pinterest', 'social' ),
		),
		'youtube' 		=> array(
			'key' 		=> 'youtube_url',
			'icon' 		=> twentytwenty_the_theme_svg( 'youtube', 'social' ),
		),
		'wikipedia' 		=> array(
			'key' 		=> 'wikipedia_url',
			'icon' 		=> twentytwenty_the_theme_svg( 'wikipedia', 'social' ),
		)
	);
	$options = apply_filters( 'ea_social_link_options', $options );
	$output = array();
	$seo_data = get_option( 'wpseo_social' );
	foreach( $options as $social => $settings ) {
		$url = !empty( $seo_data[ $settings['key'] ] ) ? $seo_data[ $settings['key'] ] : false;
		if( !empty( $url ) && !empty( $settings['prepend'] ) )
			$url = $settings['prepend'] . $url;

		if( $url && !empty( $settings['icon'] ) )
			$output[] = '<a href="' . esc_url_raw( $url ) . '" class="follow-me-links" rel="nofollow noopener noreferrer"><span class="follow-me-icon" aria-hidden="true">' . $settings['icon'] . '</span><span class="screen-reader-text">' . $social . '</span></a>';
	}
	if( !empty( $output ) )
		return '<p class="social-links">' . join( ' ', $output ) . '</p>';
}
add_shortcode( 'social_links', 'ea_social_links' );

Search the site


Address

123 Main Street
Town
City
P05T C0D3

Tel: 01234 567 899

Mob: 01234 567 899

Email: ben@gomopress.com


Copyright 2023. Blah blah blah Company Limited