Disqus评论框在WordPress新旧文章中不显示问题求助
Let's walk through the most likely fixes for your issue—since both Disqus and the native WP comment box are missing, this points to a core rendering or template structure problem first, not just a Disqus setting.
1. Fix the Broken HTML Structure in single.php
Looking at your modified single.php code, there are critical HTML tag errors that are breaking your page's DOM structure. Browsers will ignore or misrender content after invalid markup, which is probably why your comment templates aren't showing up at all.
Here's the corrected version of your code:
<div id="primary" class="content-area"> <?php $archive_content_classes = apply_filters( 'islemag_archive_content_classes', array( 'islemag-content-left', 'col-md-9' ) ); ?> <div <?php if ( ! empty( $archive_content_classes ) ) { echo 'class="' . implode( ' ', $archive_content_classes ) . '"'; } ?>> <main id="main" class="site-main" role="main"> <?php while ( have_posts() ) : the_post(); get_template_part( 'template-parts/content', 'single' ); comments_template(); endwhile; ?> </main><!-- #main --> </div><!-- .islemag-content-left --> </div><!-- #primary -->
Key fixes made:
- Removed the invalid
//closing of div tagcomment (HTML uses<!-- comment -->syntax, not line comments) - Fixed the duplicate
</div><!-- #primary -->closing tag (you had two, but only one opening#primarydiv) - Properly closed the inner content div that was left unopened in your original code
2. Verify Comment Status for Your Posts
Even if you've checked the backend settings, let's confirm the actual comment status for your posts directly in the template. Add this debug code right before comments_template(); in single.php:
<?php // Debug line to check comment status echo '<p style="color: red;">Comments Open: ' . (comments_open() ? 'YES' : 'NO') . '</p>'; comments_template(); ?>
If this outputs "NO", double-check the Discussion panel on the individual post edit screen—sometimes post-specific settings override the site-wide defaults.
3. Check content-single.php for Interference
Your single.php calls get_template_part( 'template-parts/content', 'single' );—open that file and make sure there's no code that's hiding or overriding the comment box. Look for conditional logic like:
// This would block comments from showing if ( ! comments_open() ) { return; }
Or any code that might be unhooking comment-related actions.
4. Test Without Disqus First
Temporarily deactivate the Disqus plugin and refresh your post. If the native WP comment box still doesn't show up, the issue is not with Disqus—it's a WordPress core or theme problem. In that case:
- Switch to a default theme like Twenty Twenty-One to see if comments work there (this rules out theme-specific issues)
- Disable all other plugins one by one to check for conflicts
5. Check for Removed Comment Hooks in functions.php
Some themes or custom code remove comment-related hooks. Open your theme's functions.php file and look for lines like:
remove_action( 'comment_form_before', ... ); remove_action( 'wp_enqueue_scripts', 'comment-reply' );
These would prevent the comment box or its required scripts from loading.
Start with fixing the HTML structure first—broken markup is the most likely culprit here, since it's preventing the rest of your template from rendering correctly.
内容的提问来源于stack exchange,提问作者Divya

