WordPress.org

Ready to get started?Download WordPress

Forums

comments_popup_link() change hash to #c? (3 posts)

  1. sepp88
    Member
    Posted 3 years ago #

    hey guys, the comment_popup_link links to the permalink with a #comment hash at the end!

    <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
    Is it possible to overwrite that behaviour to just have "#c" at the end so it's shorter?

    thank you

    ps: the same would be interesing for

    <?php cancel_comment_reply_link(); ?>

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    what is the big idea behind this?

    probably quite difficult to achieve:

    there is no filter hook available to do this.
    this #comments is hardcoded in /wp-includes/comment-template.php:

    518      function get_comments_link($post_id = 0) {
     519      return get_permalink($post_id) . '#comments';
     520  }

    it also corresponds to the anchor with the same id in comment_form() (? not quite sure)

    -------
    'cancel_comment_reply_link()' does have a filter hook: 'cancel_comment_reply_link' which you could use to change #respond.

    again, #respond corresponds to an anchor id in comment_form()

  3. sepp88
    Member
    Posted 3 years ago #

    thank you, i just thought there might be a way to change that so it's shorter. Thank you

Topic Closed

This topic has been closed to new replies.

About this Topic