Support » Plugin: Disqus Comment System » Disqus Header Code Showing Up Outside the Header

  • I’m working on a new theme for my site and it appears that the Disqus header code isn’t staying in the wordpress header but is being injected into different odd spots within the theme. This code is showing up in various elements of the theme.

    // <![CDATA[
            var disqus_shortname = 'vgrevolution';
            (function () {
                var nodes = document.getElementsByTagName('span');
                for (var i = 0, url; i < nodes.length; i++) {
                    if (nodes[i].className.indexOf('dsq-postid') != -1) {
                        nodes[i].parentNode.setAttribute('data-disqus-identifier', nodes[i].getAttribute('rel'));
                        url = nodes[i].parentNode.href.split('#', 1);
                        if (url.length == 1) { url = url[0]; }
                        else { url = url[1]; }
                        nodes[i].parentNode.href = url + '#disqus_thread';
                    }
                }
                var s = document.createElement('script'); s.async = true;
                s.type = 'text/javascript';
                s.src = '//' + 'disqus.com/forums/' + disqus_shortname + '/count.js';
                (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
            }());
        //]]>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    When the plugin is off obviously there is no issue. The theme developer sent me this note “for some reason it’s not putting the script in the header of the theme but instead finding a DOM element to stick the script into – the question is what is it looking for? One possibility is that somehow there is a function name or CSS selector that has the exact same name as something already used by the theme and it’s confusing things. ” and said I should reach out to you guys since it’s an issue with the plugin.

    http://wordpress.org/plugins/disqus-comment-system/

  • The topic ‘Disqus Header Code Showing Up Outside the Header’ is closed to new replies.