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 the following new line below it:

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

Add this new display_inline_share_shortcode() function above it:

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.

Need Help?

Use the comment form to ask for help and share ideas or pay me $38.95 to do this for you. I can be hired through WP Service Masters.

Win the battle. Social Warfare Dynamik Website Builder Author Pro

Leave a Reply

25 Comments on "How to Add a Social Sharing Shortcode to Monarch from Elegant Themes"

Notify of
Sort by:   newest | oldest | most voted
wpDiscuz

Free to your inbox

Join our mailing list to receive the latest news and updates from JournalXtra.

You have Successfully Subscribed!