Disqus Comment Count Link

Hi there, seem to be having issues with the Comment Count Link. Comments are getting posted but at the top of the article it still says “leave a Comment” even though I have changed that to “Make a Comment” under Community & Comments Configuration in the Disqus settings.

Any help would be appreciated.

https://www.mad-daily.com/blacklist-offer-leads-to-eds-apology/

Regards

Hi @SEVERO,

That’s the default text of comment form. To change it, please add the following code under functions.php file locates in your child theme:

add_filter('x_entry_meta_comments_link', 'x_change_comment_link');
function x_change_comment_link($link){
	global $post;
	include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
	if ( is_plugin_active( 'tco-disqus-comments/tco-disqus-comments.php' ) ) {
		return get_permalink( $post->ID ) . '#comments';
	}
	return $link;
}
add_filter( 'gettext', 'x_edit_texts' );
function x_edit_texts($translation){
	$translation = str_ireplace('Leave a Comment', 'Make a Comment', $translation);
	return $translation;
}

Hope it helps :slight_smile:

Hi there, yes that has worked but two comments have been made on that post so it should be saying “2 Comments”.

Any ideas to why that hasn’t changed?

Regards

Hi @SEVERO,

Please update the previous code to this:

add_filter('x_entry_meta_comments_link', 'x_change_comment_link');
 function x_change_comment_link($link){
	global $post;
	include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
	if ( is_plugin_active( 'tco-disqus-comments/tco-disqus-comments.php' ) ) {
		return get_permalink( $post->ID ) . '#disqus_thread';
	}
	return $link;
}
add_filter( 'gettext', 'x_edit_texts' );
function x_edit_texts($translation){
	$translation = str_ireplace('Leave a Comment', 'Make a Comment', $translation);
	return $translation;
}

Hope it helps :slight_smile:

Sorry, that didn’t work :disappointed:

Hi,

Please try this code instead

function x_integrity_entry_meta() {
    //
    // Author.
    //
    $author = sprintf( '<span><i class="x-icon-pencil" data-x-icon-s="&#xf303;"></i> %s</span>',
      get_the_author()
    );
    //
    // Date.
    //
    $date = sprintf( '<span><time class="entry-date" datetime="%1$s"><i class="x-icon-calendar" data-x-icon-s="&#xf073;"></i> %2$s</time></span>',
      esc_attr( get_the_date( 'c' ) ),
      esc_html( get_the_date() )
    );
    //
    // Categories.
    //
    if ( get_post_type() == 'x-portfolio' ) {
      if ( has_term( '', 'portfolio-category', NULL ) ) {
        $categories        = get_the_terms( get_the_ID(), 'portfolio-category' );
        $separator         = ', ';
        $categories_output = '';
        foreach ( $categories as $category ) {
          $categories_output .= '<a href="'
                              . get_term_link( $category->slug, 'portfolio-category' )
                              . '" title="'
                              . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                              . '"><i class="x-icon-bookmark" data-x-icon-s="&#xf02e;"></i> '
                              . $category->name
                              . '</a>'
                              . $separator;
        }
        $categories_list = sprintf( '<span>%s</span>',
          trim( $categories_output, $separator )
        );
      } else {
        $categories_list = '';
      }
    } else {
      $categories        = get_the_category();
      $separator         = ', ';
      $categories_output = '';
      foreach ( $categories as $category ) {
        $categories_output .= '<a href="'
                            . get_category_link( $category->term_id )
                            . '" title="'
                            . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                            . '"><i class="x-icon-bookmark" data-x-icon-s="&#xf02e;"></i> '
                            . $category->name
                            . '</a>'
                            . $separator;
      }
      $categories_list = sprintf( '<span>%s</span>',
        trim( $categories_output, $separator )
      );
    }
    //
    // Comments link.
    //
    if ( comments_open() ) {
      $title  = apply_filters( 'x_entry_meta_comments_title', get_the_title() );
      $link   = apply_filters( 'x_entry_meta_comments_link', get_comments_link() );
      $number = apply_filters( 'x_entry_meta_comments_number', get_comments_number() );
        $text = ( 0 == $number ) ? __( 'Leave a Comment', '__x__' ) : sprintf( _n( '%s Comment', '%s Comments', $number, '__x__' ), $number );
$comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments"><i class="x-icon-comments" data-x-icon-s="&#xf086;"></i> %3$s</a></span>',
        esc_url( $link ). '#disqus_thread',
        esc_attr( sprintf( __( 'Leave a comment on: &ldquo;%s&rdquo;', '__x__' ), $title ) ),
        $text
      );
    } else {
      $comments = '';
    }
    //
    // Output.
    //
    if ( x_does_not_need_entry_meta() ) {
      return;
    } else {
      printf( '<p class="p-meta">%1$s%2$s%3$s%4$s</p>',
        $author,
        $date,
        $categories_list,
        $comments
      );
    }
  }
  
add_filter( 'gettext', 'x_edit_texts' );
function x_edit_texts($translation){
    $translation = str_ireplace('Leave a Comment', 'Make a Comment', $translation);
    return $translation;
}

If that doesn’t work, please provide us your wordpress admin login in Secure Note

Thanks

Sorry, that didn’t work either.

Hi There,

Would you mind providing us with login credentials(by clicking on the Secure Note button at the bottom) so we can take a closer look? To do this, you can make a post with the following info:

  • Link login to your site
  • WordPress Admin username / password

Thanks.

Hi there, they should be above.

Regards

Hey @SEVERO,

I’ve switched back to this code and the disqus comment count is working now:

add_filter('x_entry_meta_comments_link', 'x_change_comment_link');
function x_change_comment_link($link){
	global $post;
	include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
	if ( is_plugin_active( 'tco-disqus-comments/tco-disqus-comments.php' ) ) {
		return get_permalink( $post->ID ) . '#disqus_thread';
	}
	return $link;
}

Cheers!

AWESOME!!!

Thank you so much! :blush:

You’re welcome! :slight_smile:

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