• Resolved elizajane

    (@elizajane)


    Hello, I would like to target the social icons in the footer to open in a new window or tab rather than the same window. I have created a child theme. Is there a snippet of code that can be used for this?
    BTW: Thanks for a great theme.

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @elizajane,

    Thank you for reaching out. How are you? ??

    It’s a great thing that you already created a child theme.
    In order to make this modification, it is required to add some JavaScript code.
    Please use the following steps:

    1. Create “js” folder inside the currently active Go Child Theme.
    2. Create a “custom.js” file in the above-mentioned “js” folder.
    3. Add the following JS code into the “custom.js” file:

    window.onload = function(){
      var anchors = document.getElementsByClassName('social-icons__icon');
      for (var i=0; i<anchors.length; i++){
        anchors[i].setAttribute('target', '_blank');
      }
    }

    4. Add the following code at the bottom of the “functions.php” file in the folder of the currently active Go Child Theme:

    function wpb_adding_scripts() {
        wp_register_script('custom_js', get_stylesheet_directory_uri() . '/js/custom.js', array('jquery'),'1.1', true);
        wp_enqueue_script('custom_js');
    } 
    
    add_action( 'wp_enqueue_scripts', 'wpb_adding_scripts', 999 ); 

    Save all files and try clicking on the footer icons.

    Let me know if this worked for you. ??

    Best Regards,
    Pavle

    • This reply was modified 4 years, 4 months ago by gdpavle.
    Thread Starter elizajane

    (@elizajane)

    Hi Pavle,
    Thank you that worked a treat.
    I really appreciate you getting back to me.
    All the best, Eliza

    Hey @elizajane,

    You’re most welcome. Have a wonderful day.

    Best Regards,
    Pavle

    I need to remove the persistent icons for LinkedIn and Pinterest. Why is this not in customize ? Please advise.

    • This reply was modified 4 years, 4 months ago by janwat.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to target social icons in footer’ is closed to new replies.