get_comments_link() WP 1.0
Retrieves the link to the current post comments.
Works based on: get_permalink()
Basis of: comments_link()
Hooks from the function
Return
String. The link to the comments.
Usage
get_comments_link( $post_id );
- $post_id(int/WP_Post)
- Post ID or WP_Post object.
Default: global $post
Changelog
Since 1.5.0 | Introduced. |
Code of get_comments_link() get comments link WP 5.6
function get_comments_link( $post_id = 0 ) {
$hash = get_comments_number( $post_id ) ? '#comments' : '#respond';
$comments_link = get_permalink( $post_id ) . $hash;
/**
* Filters the returned post comments permalink.
*
* @since 3.6.0
*
* @param string $comments_link Post comments permalink with '#comments' appended.
* @param int|WP_Post $post_id Post ID or WP_Post object.
*/
return apply_filters( 'get_comments_link', $comments_link, $post_id );
}Related Functions
From tag: Comments
- comment_link()
- comments_template()
- get_comment_author()
- get_comment_author_link()
- get_comment_author_url()
- get_comment_excerpt()
More from tag: Link (URL)
- admin_url()
- attachment_url_to_postid()
- build_query()
- content_url()
- get_edit_post_link()
- get_edit_term_link()
- get_home_url()
- get_post_embed_url()
- get_post_permalink()
- get_post_type_archive_link()
- get_privacy_policy_url()
- get_rest_url()
More from category: Comments
- cancel_comment_reply_link()
- comment_author_email_link()
- comment_form()
- comment_form_title()
- comment_id_fields()
- comment_text()
- comment_type()
- comments_link()
- comments_number()
- comments_popup_link()
- get_avatar()
- get_avatar_data()
- get_avatar_url()
- get_cancel_comment_reply_link()
- get_comment()
- get_comment_author_email()
- get_comment_reply_link()
- get_comment_text()
- get_comment_type()
- get_comments()
- get_comments_number()
- get_edit_comment_link()
- get_page_of_comment()
- get_previous_comments_link()
- is_comment_feed()
- is_trackback()
- next_comments_link()
- paginate_comments_links()
- previous_comments_link()
- sanitize_comment_cookies()
- the_comments_pagination()
- wp_count_comments()
- wp_delete_comment()
- wp_get_current_commenter()
- wp_handle_comment_submission()
- wp_insert_comment()
- wp_list_comments()
- wp_new_comment()
- wp_notify_moderator()
- wp_notify_postauthor()
- wp_set_comment_cookies()
- wp_set_comment_status()
- wp_transition_comment_status()
- wp_update_comment()
- wp_update_comment_count()