[wp-trac] [WordPress Trac] #33383: Comment reply links are always to first comment form on a page even when $withcomments variable is set

WordPress Trac noreply at wordpress.org
Sat Aug 15 20:12:29 UTC 2015


#33383: Comment reply links are always to first comment form on a page even when
$withcomments variable is set
--------------------------+-----------------------------
 Reporter:  johnh10       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Comments      |    Version:  4.2.4
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Using $withcomments to allow comments to be displayed on main index page,
 clicking 'reply' to any comment on any post reloads the index page with
 the focus on the first post's comment form, and ALL comment forms now have
 'Leave a Reply to [NAME]'.

 The focus should be on the target post's comment form, and only that
 comment form should have 'Leave a Reply to [NAME]'.

 How to reproduce:

 1. Clean WordPress install.

 2. Use default theme Twenty Twelve or another.

 3. Settings->Discussion : Enable threaded comments should be checked by
 default.

 4. Edit theme index page and add comment code after get_template_part
 function that displays the post content. For instance, index.php loop for
 Twenty Twelve theme:


 {{{
                         <?php while ( have_posts() ) : the_post(); ?>
                                 <?php get_template_part( 'content',
 get_post_format() ); ?>
                                 <?php
                                         // If comments are open or we have
 at least one comment, load up the comment template.
                                         if ( comments_open() ||
 get_comments_number() ) :
                                                 $withcomments=1;
 comments_template();
                                         endif;
                                 ?>
                         <?php endwhile; ?>
 }}}

 5. WordPress install should come with a 'Hello World' post. Create and
 approve a generic comment for this post.

 6. Create a new post and publish. Create and approve a generic comment for
 this post too.

 7. View the Site home page. It should show your two posts, each with a
 comment that shows a 'reply' link. On the last post's comment, click the
 'reply' link.

 8. Notice it will reload the home page, but the focus will be on the
 comment form for the first post, not the one you are trying to leave a
 comment reply for.

 Also notice both comment forms will display the same 'Leave a Reply to
 [NAME]'.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/33383>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list