The post_comments_feed_link WordPress PHP filter allows you to modify the post comments feed permalink.
Usage
add_filter('post_comments_feed_link', 'your_custom_function', 10, 1); function your_custom_function($url) { // your custom code here return $url; }
Parameters
$url
(string) – The post comments feed permalink.
More information
See WordPress Developer Resources: post_comments_feed_link
Examples
Add a custom parameter to the post comments feed link
This code adds a custom parameter utm_source
to the post comments feed link.
add_filter('post_comments_feed_link', 'add_custom_parameter', 10, 1); function add_custom_parameter($url) { $url = add_query_arg('utm_source', 'my_custom_source', $url); return $url; }
Change the post comments feed link to use a different domain
This code changes the domain of the post comments feed link to mycustomdomain.com
.
add_filter('post_comments_feed_link', 'change_domain', 10, 1); function change_domain($url) { $parsed_url = parse_url($url); $new_url = str_replace($parsed_url['host'], 'mycustomdomain.com', $url); return $new_url; }
Add a custom path to the post comments feed link
This code adds a custom path /custom-path/
to the post comments feed link.
add_filter('post_comments_feed_link', 'add_custom_path', 10, 1); function add_custom_path($url) { $url = str_replace('/comments/feed/', '/custom-path/comments/feed/', $url); return $url; }
Change the post comments feed link to use HTTPS
This code ensures that the post comments feed link uses HTTPS instead of HTTP.
add_filter('post_comments_feed_link', 'force_https', 10, 1); function force_https($url) { $url = set_url_scheme($url, 'https'); return $url; }
Remove the post comments feed link
This code removes the post comments feed link by returning an empty string.
add_filter('post_comments_feed_link', '__return_empty_string');