Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Just Share

// Add Shortcode
function just_share( $atts ) {

	// Attributes
	$atts = shortcode_atts(
		array(
			'count' => '',
		),
		$atts,
		'share'
	);

	global $post;
		
		if ( class_exists('acf') ):
		
		$tags = array(
			'page-link' 	=> urlencode( get_permalink( $post ) ),
			'page-title'	=> urlencode( get_the_title( $post ) ),
			'thumb-url'		=> urlencode( get_the_post_thumbnail_url() ),
			'site-name'		=> urlencode( get_bloginfo( 'name' ) )
		);
		
		$shares = get_field( 'social-networks', 'option' );
		
		if ( !empty( $shares ) ) : ?>
		<ul>
			<?php foreach ( array_slice($shares, 0, $count ) as $share ) : 
				$url = $share['url-pattern'];
				foreach ( $tags as $tag => $value ) {
					$url = preg_replace( '/{'.$tag.'}/', $value, $url );
				}
			?>
				
			<li class="btn-floating" style="background-color:#<?php echo $share['color']; ?>">
				<a href="<?php echo $url ?>" target="_blank"title="<?php echo sprintf( __( 'Share on %s', 'auberge-basque' ), $share['name'] ); ?>">
					<i class="<?php echo $share['css-icon'] ?>"></i><span class="share-name"><?php echo $share['name']; ?></span>
				</a>
			</li>
				
			<?php endforeach; ?>
		</ul>
		<?php endif;
		endif;

}
add_shortcode( 'share', 'just_share' );