Title: why my HTML code in header does not work?
Last modified: March 2, 2024

---

# why my HTML code in header does not work?

 *  Resolved [Premiers](https://wordpress.org/support/users/sdnazdi/)
 * (@sdnazdi)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/why-my-html-code-in-header-does-not-work/)
 * Hi,
 * I have a small html/js code for button, and I am going to use it as a language
   switcher in my website:
 *     ```wp-block-code
       <button id="enfa-button" style="cursor: pointer; padding: 10px;">fa</button> 
   
       <script type="text/javascript">
           const button = document.getElementById('enfa-button');
           button.addEventListener('click' , enfa);
   
           let enurl = window.location.href;
           function enfa(){
               let faurl = enurl.replace("example.com", "example.com/fa");
               open(faurl, '_self');
           }
        </script>
       ```
   
 * You may change “example.com” to part/whole of url where you are testing this 
   code and “example.com/fa” with your desired url.
 * I use this code in Appearance->Customize->Header->HTML
 * and it only work when I am logged in as admin, but when I am not logged in it
   does not work.
 * There is a plugin you might know named WPCode, which allows to create shortcode
   from code snippet.
 * I created a bank snippet in WPCode snippet plugin, and inserted the above code
   into this blank snippet (code type: HTML snippet) and activate it, and inserted
   its shortcode in the same place (Appearance->Customize->Header->HTML) 
   and again
   it does not work (click not doing anything),
 * [https://ibb.co/VvSMtjr](https://ibb.co/VvSMtjr)
   [https://ibb.co/2d4p8JV](https://ibb.co/2d4p8JV)
 * however when I inserted this shortcode into a text inside posts or pages, it 
   works fine.
 * [https://ibb.co/MskB4VK](https://ibb.co/MskB4VK)
   [https://ibb.co/whRVtNW](https://ibb.co/whRVtNW)
 * Please let me know where does this issue come from?
    -  This topic was modified 2 years, 3 months ago by [Premiers](https://wordpress.org/support/users/sdnazdi/).
    -  This topic was modified 2 years, 3 months ago by [Premiers](https://wordpress.org/support/users/sdnazdi/).
    -  This topic was modified 2 years, 3 months ago by [Premiers](https://wordpress.org/support/users/sdnazdi/).
    -  This topic was modified 2 years, 3 months ago by [Premiers](https://wordpress.org/support/users/sdnazdi/).
    -  This topic was modified 2 years, 3 months ago by [Premiers](https://wordpress.org/support/users/sdnazdi/).
    -  This topic was modified 2 years, 3 months ago by [Premiers](https://wordpress.org/support/users/sdnazdi/).
    -  This topic was modified 2 years, 3 months ago by [Premiers](https://wordpress.org/support/users/sdnazdi/).

Viewing 1 replies (of 1 total)

 *  [Eduard](https://wordpress.org/support/users/cteduard/)
 * (@cteduard)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/why-my-html-code-in-header-does-not-work/#post-17470990)
 * Hello [@sdnazdi](https://wordpress.org/support/users/sdnazdi/)
 * I’m really sorry, but our policy does not offer support for custom code, be it
   implementing or debugging it. We recommend contacting a knowledgeable developer
   if you require assistance with implementing advanced solutions on your website.
 * Thank you.

Viewing 1 replies (of 1 total)

The topic ‘why my HTML code in header does not work?’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/blocksy/2.1.44/screenshot.jpg)
 * Blocksy
 * [Support Threads](https://wordpress.org/support/theme/blocksy/)
 * [Active Topics](https://wordpress.org/support/theme/blocksy/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/blocksy/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/blocksy/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Eduard](https://wordpress.org/support/users/cteduard/)
 * Last activity: [2 years, 3 months ago](https://wordpress.org/support/topic/why-my-html-code-in-header-does-not-work/#post-17470990)
 * Status: resolved