Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 5 years ago

#33383 closed defect (bug) (fixed)

Comment reply links are always to first comment form on a page even when $withcomments variable is set

Reported by: johnh10's profile johnh10 Owned by:
Milestone: 4.3 Priority: normal
Severity: normal Version: 4.2.4
Component: Comments Keywords:
Focuses: Cc:

Description

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.
  1. Use default theme Twenty Twelve or another.
  1. Settings->Discussion : Enable threaded comments should be checked by default.
  1. 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; ?>
  1. WordPress install should come with a 'Hello World' post. Create and approve a generic comment for this post.
  1. Create a new post and publish. Create and approve a generic comment for this post too.
  1. 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.
  1. 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]'.

Change History (3)

#1 @rachelbaker
9 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in r32786. See #31333.

#2 @netweb
9 years ago

  • Milestone changed from Awaiting Review to 4.3

Moving to the 4.3 milestone, the same milestone as #31333

#3 @peterwilsoncc
5 years ago

In 45787:

Comments: Include post permalink in comment reply link.

Include the post's permalink when generating reply links in get_comment_reply_link() to account for comments displayed on index and archive pages.

This reapplies [32786] which was inadvertently reverted in [42360].

Props justinahinon, donmhico.
See #33383.
Fixes #47174.

Note: See TracTickets for help on using tickets.