Skip to content

Snippet: How to Add New Social Share Options

The following snippet is an example showing how you may add custom social share buttons to the Total theme's social share functionality. By default the theme only includes the most commonly used social share options to keep the theme slim and also because it's well known that the less social share buttons you provide the more likely people are to actually use them. Now, if you want to display a whole bunch of other options we'd recommend a 3rd party service like Add This as it won't bloat up your site compared to using a WP plugin.

/**
 * Add new social share items.
 *
 * @param array $items
 */
add_filter( 'wpex_social_share_items', function ( $items ) {
	$items['whatsapp'] = array(
		'site'       => 'Whatsapp',
		'label'      => 'Whatsapp',
		'li_class'   => 'whatsapp',
		'icon_class' => 'ticon ticon-whatsapp', // to use a theme icon class
		'icon'       => '', // you could also define a custom icon using SVG code here.
		'href'       => 'https://wa.me/?text=' . rawurlencode( get_permalink() ),
	);
	return $items;
} );
All PHP snippets should be added via child theme's functions.php file or via a plugin. We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top