Comments invisible after moving WordPress to new server, while commenting still works

I moved a wordpress installation from one server to another. I dumped the DB, copied over all the files, put all DB data into a new database, changed wp-config.php to the new database info, and after the DNS servers agreed to point the domain to the new ip, the site seemed to work fine. also, I moved the wordpress installation from www.domain.tld/WP/ one folder up to www.domain.tld (without the WP subfolder), a day or two later, and that also worked fine.
I then noticed that all comments do not show up. I know the following:

  • Comments worked before the move.
  • All old and new comments are still there in the backend.
  • The line "2 comments for Post Title" is still generated correctly.
  • The comments do not show up at all, the generated html looks like this:
        <ol class="commentlist">
            <ul class="children">
</li><!-- #comment-## -->
</ul><!-- .children -->
</li><!-- #comment-## -->
        </ol><!-- .commentlist -->
  • The form to write a new comment does show up, and it works, users can write a comment, it gets queued for review, the author of the post gets an email and can allow or disallow the comment, answer it, just as usual. The comment count on that post then goes up ("3 comments for…") but the comments still won’t show up.

There is no output at all in the debug log.

Any ideas on how to fix this?

EDIT: I fixed it. It was a problem with the theme, "Destin Basic". If anyone else has that problem: in functions.php, in the function bavotasan_comment on line 382 replace (or add to)

case '' :

with

case 'comment' :

To repair the issue.

More Information:
I am guessing at the moment that there is a wordpress update which changed functionality, though that is unlikely in some way too – I did not investigate. After examining, the problem boils down to the following: The theme does not use the wordpress standard comment output, but it uses a callback function called bavotasan_comment which gets called for each comment. This function decides from the current comment type if it is a comment (and displays it as a a comment) or a pingback/trackback (which is displayed differently). it does that by a switch:

switch ( $comment->comment_type ) :

which has the three allowed values '', 'pingback', 'trackback' while '' seems to stand for "comment". but in my case, $comment->comment_type is 'comment' so the function simply falls through and does not output anything at all. As there is no error, no debug output is written.

While it is obvious that bavotasan_comment could be easily made with a default case for handling "unkown" comment types, I have no idea if comment->comment_type always was comment for a normal comment or if this is something new in a recent update, which I somewhat doubt too while it is my best guess at the moment. I can say for sure that it is reproducable in my case, even after disabling all plugins.

Also, I seem to be not the only one having trouble with this. These people here simply removed the callback function alltogether to resolve it:

https://wordpress.org/support/topic/comments-no-longer-appear-on-posts/

The post is about a month old, so there might be some update to wordpress breaking this functionality.

edit: It was not an update. I have no idea why this worked in the first place.

For the interested, here is the relevant part of functions.php including my fix at the beginning:

<?php /* this line is added by me for the syntax highlighter */
function bavotasan_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case '' :
case 'comment' :
    ?>
    <li <?php comment_class(); ?>>
        <div id="comment-<?php comment_ID(); ?>" class="comment-body">
            <div class="comment-avatar">
                <?php echo get_avatar( $comment, 55 ); ?>
            </div>
            <div class="comment-content">
                <div class="comment-author">
                    <?php echo get_comment_author_link() . ' '; ?>
                </div>
                <div class="comment-meta">
                    <?php
                    printf( __( '%1$s at %2$s', 'destin-basic' ), get_comment_date(), get_comment_time() );
                    edit_comment_link( __( 'Edit', 'destin-basic' ), '  ', '' );
                    ?>
                </div>
                <div class="comment-text">
                    <?php if ( '0' == $comment->comment_approved ) { echo '<em>' . __( 'Your comment is awaiting moderation.', 'destin-basic' ) . '</em>'; } ?>
                    <?php comment_text() ?>
                </div>
                <?php if ( $args['max_depth'] != $depth && comments_open() && 'pingback' != $comment->comment_type ) { ?>
                <div class="reply">
                    <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
                </div>
                <?php } ?>
            </div>
        </div>
        <?php
        break;

case 'pingback'  :
case 'trackback' :
    ?>
    <li id="comment-<?php comment_ID(); ?>" class="pingback">
        <div class="comment-body">
            <i class="fa fa-paperclip"></i>
            <?php _e( 'Pingback:', 'destin-basic' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(edit)', 'destin-basic' ), ' ' ); ?>
        </div>
        <?php
        break;
endswitch;
}

$299 Affordable Web Design WordPress

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Comments invisible after moving WordPress to new server, while commenting still works

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.