post_comments_link

Filters the formatted post comments link HTML.

Description

apply_filters( 'post_comments_link', (string) $formatted_link, (int|WP_Post) $post ); 

Parameters (2)

0. $formatted_link (string)
The HTML-formatted post comments link.
1. $post (int|WP_Post)
The post ID or WP_Post object.

Usage

To run the hook, copy the example below.
  1. $formatted_link = apply_filters( 'post_comments_link', $formatted_link, $post ); 
  2.  
  3. if ( !empty( $formatted_link ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the post_comments_link callback 
  2. function filter_post_comments_link( $formatted_link, $post ) { 
  3. // make filter magic happen here... 
  4. return $formatted_link
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'post_comments_link', 'filter_post_comments_link', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'post_comments_link', 'filter_post_comments_link', 10, 2 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/comment-template.php  
  1. return apply_filters( 'post_comments_link', $formatted_link, $post );