[wp-trac] [WordPress Trac] #34106: Comments should have real permalinks

WordPress Trac noreply at wordpress.org
Thu Jan 14 10:42:52 UTC 2016


#34106: Comments should have real permalinks
--------------------------+-----------------------------
 Reporter:  boonebgorges  |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Future Release
Component:  Comments      |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:
--------------------------+-----------------------------

Comment (by cadeyrn):

 Replying to [comment:6 peterwilsoncc]:
 > Occurs to me WordPress already has permalinks for comments,
 `http://example.com/post-name/?replytocom=4159`. Could these be used as
 the permalink, possibly with a new rewrite along the lines of
 `/comment/4159`?

 I believe that by under 'permalink to a comment' the reporter meant
 permalink to a page where the content is the comment itself, not the post
 + all the comments as it is now.

 This would be useful for situations where the comment is crawled by remote
 sites; eg. it's a comment in reply to something left by a
 [https://www.w3.org/TR/webmention/ webmention] and you want to make the
 comment available to be crawled, without the need of processing the post
 itself.

 Right now I achieved this as:

 in `functions.php`
 {{{#!php
 <?php
 add_filter( 'query_vars', 'add_query_var' );

 public function add_query_var($vars) {
         array_push($vars, 'comment' );
         return $vars;
 }

 add_rewrite_endpoint ( 'comment', EP_ROOT );
 }}}

 in `index.php` (various checking points have been stripped out for the
 sake of readability)
 {{{#!php
 <?php

 global $wp;
 if ( array_key_exists( 'comment', $wp->query_vars ) ) {
         $comment_id = $wp->query_vars['comment'];
         $comment = get_comment($comment_id);

         // include comment template here
         exit;
 }
 }}}

 but this feels to be a hack.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34106#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list