respond_linkfilter-hookWP 4.4.0

Filters the response URL (the link to the comments) when a post has no comments. Clicking the link takes the user to the comment form (the link contains an anchor).

Usage

add_filter( 'respond_link', 'wp_kama_respond_link_filter', 10, 2 );

/**
 * Function for `respond_link` filter-hook.
 * 
 * @param string $respond_link The default response link.
 * @param int    $post_id      The post ID.
 *
 * @return string
 */
function wp_kama_respond_link_filter( $respond_link, $post_id ){

	// filter...
	return $respond_link;
}
$respond_link(string)
The default response URL.
$id(integer)
The ID of the post for which the link is filtered.

Examples

#1 Change the link for a specific post

add_filter( 'respond_link', 'respond_link_change', 10, 2 );
function respond_link_change( $respond_link, $id ) {
	// By default, for example, it was http://wp-test.ru/my-post/#respond
	if ( 229 === $id ) {
		// It becomes http://wp-test.ru/my-post/#my-respond-box
		$respond_link = get_permalink( $id ) . '#my-respond-box';
	}

	return $respond_link;
}

#2 Change the link for all posts

add_filter( 'respond_link', 'respond_link_change' );
function respond_link_change() {
	$respond_link = get_permalink() . '#my-respond-box';

	return $respond_link;
}

Changelog

Since 4.4.0 Introduced.

Where the hook is called

comments_popup_link()
respond_link
wp-includes/comment-template.php 1698
$comments_link = apply_filters( 'respond_link', $respond_link, $post_id );

Where the hook is used in WordPress

Usage not found.