Permanlink to comment in paged comments (2 posts)

  1. onepack
    Posted 5 years ago #

    I'm trying to get the permalink working to comments that are in paged comments.

    To describe this:
    On the frontpage I have a recent comments list for users. They can click on the link of a comment and directly go to that comment.
    The comments are paged to ensure that the loading time is fast.
    The problem now lies in the comments done on older comments and thus in the subpages of the total comments collection. For instance on page 5 of the paged comments.
    The link would look like this: http://www.domain.com.posttitle/comment-page-1/#comment-38542

    Now I have the following to get the permalink:
    comment_post_ID).'#comment-'.$comment->comment_ID .'" title="'.get_the_title($comment->comment_post_ID).'" rel="nofollow">

    How can I get the page ID of comment subpages in there to make the permalink complete? Thanks for the time and help in advance!

  2. onepack
    Posted 5 years ago #

    Ok :-) having been looking for a solution for some time and finally by going through wp-includes/comment-template.php I found:
    get_comment_link and this gives the full url including subpages. :-)

    comment__post_ID) .'" title="'.get_the_title($comment->comment_post_ID).'" rel="nofollow">

    Hope this helps some other people as well.

Topic Closed

This topic has been closed to new replies.

About this Topic