A few weeks ago I released the Atlantic Wave Social Media plugin for Divi. The plugin extends the built in Divi header and footer social media icon set by adding up to 13 additional social media icons.
A customer recently asked me how it would be possible to open the social media links in a new window. Now I will probably release an update to the plugin to add this functionality, but for now I thought it would be a good idea to share a simple way of being able to do this. Even if you don’t use my plugin, being able to set your social media icons to open in a new window is a good practice.
By adding a little piece of JavaScript to your Integration tab in the Divi Theme Options, you can set the social media icons to open in a new window.
- In your WP admin, select Theme Options from the Divi menu
- Click on the Integration tab
- Make sure ‘Enable body code’ is enabled.
- Scroll down to the section where it says ‘Add code to the <body> (good for tracking codes such as google analytics)’
- Add the JavaScript code snippet below. If you already have some JavaScript there, you can just put this inside the existing <script> tags. If there is nothing there then make sure to wrap the JavaScript with <script> tags.
jQuery(document).ready(function($){ $('.et-social-icon .icon').each(function(){ $(this).attr('target', 'blank'); }); });
And there you go, all your social media icons should now open in a new window!
Leave a Reply to JonathanCancel reply