After installing the Disqus plugin, their JavaScript code started popping up as plain text on my site in several places. My hypothesis is that it pops up at the end of any loop involving the_post(). This is one of them.

Screenshot of the glitch

Here's a snippet from my front-page.php:

foreach ($terms as $term) {
    $query = new WP_Query(array(
        'post_type' => 'portfolio',
        'skill' => $term->slug,
        'orderby' => 'meta_value',
        'meta_key' => 'pf_startyear',
        'nopaging' => true,
        'order' => 'DESC',
        'posts_per_page' => 4
    <div class="box">
        <h4 class="boxTitle"><?= $term->name ?></h4>
        <div class="boxFrontContent table tblvtop">
    if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post();
                <div class="contentItem">
                    <a href="<?= get_term_link($term->slug, "skill") . "#" . $post->post_name ?>"><img src="<?= wp_get_attachment_url(get_post_meta($post->ID, "pf_img", true)) ?>" alt="<?php the_title() ?>" title="<?php the_title() ?>" class="pfItem" /></a>
                    <p><?= get_post_meta($post->ID, "pf_pitch", true) ?></p>

This is how it renders:

Output tree

Why is this happening and how can I prevent this script from breaking my site layout?


On some themes the Disqus code is rendered at a bad position within the loop. Go to the Disqus plugin within Wordpress, click the "Advanced options" tab, and then check "Output javascript in footer". That should fix this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.