How to Add a Social Sharing Shortcode to Monarch from Elegant Themes

Monarch from Elegant Themes is one of my favourite WordPress social media plugins. It can automatically display social buttons above or below content, in widget areas, in pop-ups, in flyins and in a floating bar. For such a well rounded plugin Monarch lacks one important feature: a shortcode to use to manually add social share buttons within specific pages only.

Fortunately there is something we can do about that…

How to add a new social sharing shortcode to Monarch

We need to make a couple of quick and simple changes to the Monarch plugin code.

These changes to the code will add a new social sharing shortcode to Monarch. The shortcode can be used to manually add inline social share buttons to any specific page, post or widget.

The new shortcode will be [et_social_share].

All edits are made to the plugin file monarch.php.

You will find this file in wp-content/plugins/monarch/monarch.php.

The line numbers mentioned below are accurate for Monarch version 1.3.2. The line numbers may be different for other versions of the plugin.

Use your browser’s find feature (press Ctrl+F) to locate the places where new code is to be added.

The code edits

Use an FTP program or cPanel file browser to locate the file monarch.php. You can also get to this file from the WordPress dashboard by going to the ‘Plugins’ screen to click the ‘edit’ link printed below ‘Monarch Plugin’.

Find line 122. The line begins with the WordPress action hook add_shortcode(). It looks like this:

add_shortcode( 'et_social_share_media', array( $this, 'et_social_share_media' ) );

Add the following new line below it:

add_shortcode( 'et_social_share', array( $this, 'display_inline_share_shortcode' ) );

Find the function display_inline() at around line 4189. It looks like this:

function display_inline( $content ) {
	$monarch_options = $this->monarch_options;

	if ( $this->check_applicability( $monarch_options[ 'sharing_inline_post_types' ], 'inline' ) ) {
		$content = sprintf( '%1$s%2$s%3$s',
			( 'above' == $monarch_options[ 'sharing_inline_icons_location' ] || 'above_below' == $monarch_options[ 'sharing_inline_icons_location' ] )
					? $this->generate_inline_icons( 'et_social_inline_top' )
					: '',
			( 'below' == $monarch_options[ 'sharing_inline_icons_location' ] || 'above_below' == $monarch_options[ 'sharing_inline_icons_location' ] )
					? $this->generate_inline_icons( 'et_social_inline_bottom' )
					: ''

Add this new display_inline_share_shortcode() function above it:

function display_inline_share_shortcode() {
	$monarch_options = $this->monarch_options;
	return $this->generate_inline_icons( 'et_social_inline_top' );

Save the file.

Configure the Monarch plugin

The social share buttons shown by the shortcode will use whatever configs are set under Tools > Monarch > Social Sharing > Inline.

The only difference between the inline buttons and the shortcode buttons is that the shortcode will ignore the setting that determines which post types the inline buttons display on. The shortcode share buttons will display on any page or post whether Monarch’s inline share buttons are enabled for pages, posts or neither.

Use the shortcode

The shortcode is [et_social_share]. Use it in any page or post. Put it wherever you want Monarch social share buttons to show.

Take note that…

The code edits will be overwritten when Monarch is updated to a new version. Hopefully Elegant Themes will add a shortcode for social sharing buttons in a future release. Until Elegant Themes adds the shortcode feature to the plugin you will need to add the code whenever the plugin is upgraded.

How to center Monarch social share buttons

The buttons can be centered with the following CSS.

Put the CSS in the Custom CSS box in Monarch’s general settings. The box is at the bottom of the page Tools > Monarch > General Settings. This will also affect automatically added inline social share buttons.

.et_social_networks {
	text-align: center!important;
.et_social_icons_container li {
	display: inline-block!important;

Want a Better Social Sharing Plugin?

We moved away from Monarch some time ago. We now use Social Pug, which includes click to tweet in the Pro version. It is reasonably priced and comes with a migration tool that restores social share counts captured by other plugins.

Need Help?

Use the comment form to ask for help and share ideas or pay WP Service Masters to do this for you. Licensed installers of Social Pug Pro.

Sharing is caring!

Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Newest Most Voted
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x