Site logo

Archived topic

Reloading current page when clicking comment link (custom post)

1 reply · Started by Masud on December 3, 2022

Viewing posts 1–2 of 2

I've added comment link in custom post type using this tutorial.

<div id="showcomments">		
<i class="fa fa-comments-o" aria-hidden="true"></i>
 <?php comments_popup_link( __( 'Comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) ); ?> 		
</div>

 <div id='cp-comment-area' class="cp-comment-link">
	<?php comments_template (); ?>
</div>

But the problem is, when I click on that link, it's reloading current page.
When there is no comment, that link contains #respond at the end of the url

<a href="https://maysite.com/custompost/post1#respond">Comment</a>

When there are comments, that link contains #comments at the end of the url

<a href="https://maysite.com/custompost/post2#comments">Comment</a>

And for both cases reloading the page.

I can see there is no slash / before # in both cases.

Hi there,

I just tested the code, it's working properly.

Can you disable all plugins and custom functions to test?

This archived topic is closed to new replies.