Based on your comment, you can get the comment ID via JavaScript, and here's a sample function
you can use/try:
<script>
function getCommentIdFromUrl( url ) {
return (
( url && /#comment-(\d+)$/.test( url ) ) ||
( location.hash && /^#comment-(\d+)$/.test( location.hash ) )
) && RegExp.$1;
}
</script>
So if the URL of the current page is http://example.com/hello-world/#comment-76, getCommentIdFromUrl()
would return 76
.
Alternatively, you could ignore the above function
and use the second expression with a var
iable, like so:
var comment_ID = location.hash && /^#comment-(\d+)$/.test( location.hash ) && RegExp.$1;
Hope that helps.
[EDIT] In reply to your comment on my answer, you can ignore all the above code, and use this instead:
var
// Check if the current URL ends with a #comment-123, where 123 is the comment ID.
is_comment_link = /#comment-(\d+)$/.test( location.href ),
// Removes the #comment- portion from the URL hash, and get the comment ID.
comment_ID = is_comment_link && location.hash.substring(9);
Or you could also use:
var is_comment_link, comment_ID;
if ( /#comment-(\d+)$/.test( location.href ) ) {
is_comment_link = true;
comment_ID = RegExp.$1;
}