• Resolved Annie

    (@peaktoplate)


    Hello,

    I understand why my social icons show the opens in new window icon, but I’m wondering if anyone knows a way to get my social icons to open in the same tab/window. I don’t have the box checked on the simple social icons plugin to open in a new window, but they do open in a new tab and I don’t see a way to change that.

    Thanks for your help!

    Annie

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Steve Jones

    (@stevejonesdev)

    Hello @peaktoplate,

    I don’t think the simple social icons plugin has a setting or filter to change the target attribute value.

    You could use a bit of JavaScript to modify the link target and set it to open in the same window.

    Here is an example:

    function modify_simple_social_icons_link_target() {
        ?>
        <script>
            document.addEventListener('DOMContentLoaded', function() {
                var socialIcons = document.querySelectorAll('.simple-social-icons ul li a');
                socialIcons.forEach(function(icon) {
                    // Set the target attribute to '_self' to open links in the same window
                    icon.target = '_self';
                });
            });
        </script>
        <?php
    }
    add_action('wp_footer', 'modify_simple_social_icons_link_target');
    
    Plugin Author Steve Jones

    (@stevejonesdev)

    @peaktoplate, actually now that I looked at the plugin there is a checkbox on the widget that says “Open links in new window?”. Uncheck that and your links should open in the same window.

    https://capture.dropbox.com/j37Unj6BnqnThWHc

    Thread Starter Annie

    (@peaktoplate)

    @stevejonesdev thanks for looking into it! I do have the “open in new window” box unchecked, but the default is still set to open in a new tab so the new window icon still shows up. Would I add the code you mentioned in the additional CSS section?

    Thanks!

    Annie

    Thread Starter Annie

    (@peaktoplate)

    @stevejonesdev nevermind. I added the code to the plugin and it fixed my issue. Thank you so much for your help!

    Annie

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Change social icons to open in same tab’ is closed to new replies.