Comments not showing up

Hi, please I need your help.

I have been having this comment issue since I changed my domain name.

Whenever comment is active on a post, the comment doesn’t display plus the header doesn’t function as it normally does.

PLEASE help because I don’t know where to start from :pleading_face:

Hello @Mrbiizy,

Thanks for writing in! I have investigated your issue and this is all coming from your child theme’s custom templates. You have added several template modifications and your comments is not displaying because of your broken Comment callback code. You have this added in your child theme’s functions.php file:

if ( ! function_exists( 'my_comment' ) ) :
	function my_comment( $comment, $args, $depth ) {

		$GLOBALS['comment'] = $comment;
		switch ( $comment->comment_type ) :
		case 'pingback' :  // 1
      	case 'trackback' : // 1
      	?>

      	<li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
      		<p><?php _e( 'Pingback:', '__x__' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', '__x__' ), '<span class="edit-link">', '</span>' ); ?></p>

      		<?php
      		break;
      		default : // 2
      		GLOBAL $post;
      		if ( X_WOOCOMMERCE_IS_ACTIVE ) :
      			$rating = esc_attr( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) );
      		endif;
      		$avatar_variation = ( x_is_product() ) ? ' x-img-thumbnail' : '';
      		?>

      		<li id="li-comment-<?php comment_ID(); ?>" <?php x_comment_schema ('li'); ?> <?php comment_class(); ?>>

      		

      		<article id="comment-<?php comment_ID(); ?>" class="comment">
      			<!--The comment header wrap-->
      			<header class="my-comment-header">
      				<?php x_comment_schema ('item'); ?>

      				<div class="my-comment-header-left">
      				<?php //Comment author avatar
      				printf( '<div class="my-comment-img">%1$s %2$s</div>',
      					'<span class="avatar-wrap cf' . $avatar_variation . '">' . get_avatar( $comment, 120 ) . '</span>',
      					( $comment->user_id === $post->post_author ) ? '<span class="bypostauthor">' . __( '<i class="my-comment-main-post-author" data-x-icon-s="&#xf521;"></i>', '__x__' ) . '</span>' : ''
      				);
      				?>
      				</div>

      				<div class="my-comment-header-right">
      				<?php
      				//Print the comment author name
      				printf( '<cite class="my-comment-author" itemprop="author">%1$s</cite>',
      					get_comment_author_link()
      				);
      				//Print the comment date and time
      				printf( '<div><a href="%1$s" class="my-comment-time"><time itemprop="datePublished" datetime="%2$s">%3$s</time></a></div>',
      					esc_url( get_comment_link( $comment->comment_ID ) ),
      					get_comment_time( 'c' ),
      					sprintf( __( '%1$s at %2$s', '__x__' ),
      						get_comment_date(), //Date
      						get_comment_time() //Time
      					)
      				);

      				//Edit the comment
      				edit_comment_link( __( '<i class="my-icon-edit" data-x-icon-s="&#xf044;"></i> Edit', '__x__' ) );
      				?>
      				</div>

      				<?php //If it is a product review
      				if ( x_is_product() && get_option('woocommerce_enable_review_rating') == 'yes' && !empty( $rating ) ) : ?>
      					<div class="star-rating-container">
      						<div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating" class="star-rating" title="<?php echo sprintf( __( 'Rated %d out of 5', '__x__' ), $rating ) ?>">
      							<span style="width:<?php echo ( intval( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) ) / 5 ) * 100; ?>%"><strong itemprop="ratingValue"><?php echo intval( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) ); ?></strong> <?php _e( 'out of 5', '__x__' ); ?></span>
      						</div>
      					</div>
      				<?php endif; ?>
      			</header>

      			<?php //If comment has not been approved
      			if ( '0' == $comment->comment_approved ) : ?>
      				<p class="x-comment-awaiting-moderation"><?php _e( 'Hello Chief! Your comment is awaiting moderation. Thank you.', '__x__' ); ?></p>
      			<?php endif; ?>

      			<section class="my-comment-content" itemprop="description">
      			<?php //My comment texts
      			comment_text(); ?>
      			</section>

      			<?php //My comment texts if it is a product review
      			if ( ! x_is_product() ) : ?>

      				<div class="my-comment-reply">
      				<?php //My comment reply
      				comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply <span class="comment-reply-link-after"><i class="my-comment-reply-icon" data-x-icon-s="&#xf3e5;"></i></span>', '__x__' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
      				</div>

      			<?php endif; ?>
      		</article>
      		<?php
      		break;
      	endswitch;
      }
  endif;

The built-in integrity comment callback is this:

// Individual Comment
// =============================================================================

//
// 1. Pingbacks and trackbacks.
// 2. Normal Comments.
//

if ( ! function_exists( 'x_integrity_comment' ) ) :
  function x_integrity_comment( $comment, $args, $depth ) {

    $GLOBALS['comment'] = $comment;
    switch ( $comment->comment_type ) :
      case 'pingback' :  // 1
      case 'trackback' : // 1
    ?>
    <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
      <p><?php _e( 'Pingback:', '__x__' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', '__x__' ), '<span class="edit-link">', '</span>' ); ?></p>
    <?php
        break;
      default : // 2
      GLOBAL $post;
      if ( X_WOOCOMMERCE_IS_ACTIVE ) :
        $rating = esc_attr( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) );
      endif;
      $avatar_variation = ( x_is_product() ) ? ' x-img-thumbnail' : '';
    ?>
    <li id="li-comment-<?php comment_ID(); ?>" <?php echo apply_filters ('x_woocommerce_review_schema_attributes', ''); ?> <?php comment_class(); ?>>
      <?php
      printf( '<div class="x-comment-img">%1$s %2$s</div>',
        '<span class="avatar-wrap cf' . $avatar_variation . '">' . get_avatar( $comment, 120 ) . '</span>',
        ( $comment->user_id === $post->post_author ) ? '<span class="bypostauthor">' . __( 'Post<br>Author', '__x__' ) . '</span>' : ''
      );
      ?>
      <article id="comment-<?php comment_ID(); ?>" class="comment">        
        <header class="x-comment-header">
          <?php echo apply_filters ('x_woocommerce_review_schema_item', ''); ?>
          <?php
          printf( '<cite class="x-comment-author" itemprop="author">%1$s</cite>',
            get_comment_author_link()
          );
          printf( '<div><a href="%1$s" class="x-comment-time"><time itemprop="datePublished" datetime="%2$s">%3$s</time></a></div>',
            esc_url( get_comment_link( $comment->comment_ID ) ),
            get_comment_time( 'c' ),
            sprintf( __( '%1$s at %2$s', '__x__' ),
              get_comment_date(),
              get_comment_time()
            )
          );
          edit_comment_link( __( '<i class="x-icon-edit" data-x-icon-s="&#xf044;"></i> Edit', '__x__' ) );
          ?>
          <?php if ( x_is_product() && get_option('woocommerce_enable_review_rating') == 'yes' && !empty( $rating ) ) : ?>
            <div class="star-rating-container">
              <div <?php echo apply_filters ('x_woocommerce_review_schema_rating_attributes', ''); ?> class="star-rating" title="<?php echo sprintf( __( 'Rated %d out of 5', '__x__' ), $rating ) ?>">
                <span style="width:<?php echo ( intval( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) ) / 5 ) * 100; ?>%"><strong itemprop="ratingValue"><?php echo intval( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) ); ?></strong> <?php _e( 'out of 5', '__x__' ); ?></span>
              </div>
            </div>
          <?php endif; ?>
        </header>
        <?php if ( '0' == $comment->comment_approved ) : ?>
          <p class="x-comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', '__x__' ); ?></p>
        <?php endif; ?>
        <section class="x-comment-content" itemprop="description">
          <?php comment_text(); ?>
        </section>
        <?php if ( ! x_is_product() ) : ?>
        <div class="x-reply">
          <?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply <span class="comment-reply-link-after"><i class="x-icon-reply" data-x-icon-s="&#xf3e5;"></i></span>', '__x__' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
        </div>
        <?php endif; ?>
      </article>
    <?php
        break;
    endswitch;

  }
endif;

Please check your code and compare it to the original callback. If you are not the one who created the custom PHP comment callback code, please ask your developer instead.

Please note that custom coding is outside the scope of our support. Issues that might arise from the use of custom code and further enhancements should be directed to a third-party developer.

Best Regards.

Okay. Thanks a million!

Hi @Mrbiizy,

You’re welcome and it’s our pleasure to help you! If you have any other concerns or clarifications regarding our theme features, feel free to open up a new thread.

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.