Title: get_search_comments_feed_link
Published: April 25, 2014
Last modified: August 20, 2026

---

# get_search_comments_feed_link( string $search_query = ”, string $feed = ” ): string

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/get_search_comments_feed_link/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_search_comments_feed_link/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_search_comments_feed_link/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/get_search_comments_feed_link/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/get_search_comments_feed_link/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_search_comments_feed_link/?output_format=md#changelog)

Retrieves the permalink for the search results comments feed.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_search_comments_feed_link/?output_format=md#parameters)󠁿

 `$search_query`stringoptional

Search query.

Default:`''`

`$feed`stringoptional

Feed type. Possible values include `'rss2'`, `'atom'`.
 Default is the value of 
[get_default_feed()](https://developer.wordpress.org/reference/functions/get_default_feed/).

Default:`''`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_search_comments_feed_link/?output_format=md#return)󠁿

 string The comments feed search results permalink.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_search_comments_feed_link/?output_format=md#source)󠁿

    ```php
    function get_search_comments_feed_link( $search_query = '', $feed = '' ) {
    	global $wp_rewrite;

    	if ( empty( $feed ) ) {
    		$feed = get_default_feed();
    	}

    	$link = get_search_feed_link( $search_query, $feed );

    	$permastruct = $wp_rewrite->get_search_permastruct();

    	if ( empty( $permastruct ) ) {
    		$link = add_query_arg( 'feed', 'comments-' . $feed, $link );
    	} else {
    		$link = add_query_arg( 'withcomments', 1, $link );
    	}

    	/** This filter is documented in wp-includes/link-template.php */
    	return apply_filters( 'search_feed_link', $link, $feed, 'comments' );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/link-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/link-template.php#L1268)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/link-template.php#L1268-L1287)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_search_comments_feed_link/?output_format=md#hooks)󠁿

 [apply_filters( ‘search_feed_link’, string $link, string $feed, string $type )](https://developer.wordpress.org/reference/hooks/search_feed_link/)

Filters the search feed link.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_search_comments_feed_link/?output_format=md#related)󠁿

| Uses | Description | 
| [get_search_feed_link()](https://developer.wordpress.org/reference/functions/get_search_feed_link/)`wp-includes/link-template.php` |

Retrieves the permalink for the search results feed.

  | 
| [get_default_feed()](https://developer.wordpress.org/reference/functions/get_default_feed/)`wp-includes/feed.php` |

Retrieves the default feed.

  | 
| [WP_Rewrite::get_search_permastruct()](https://developer.wordpress.org/reference/classes/wp_rewrite/get_search_permastruct/)`wp-includes/class-wp-rewrite.php` |

Retrieves the search permalink structure.

  | 
| [add_query_arg()](https://developer.wordpress.org/reference/functions/add_query_arg/)`wp-includes/functions.php` |

Retrieves a modified URL query string.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 2 more](https://developer.wordpress.org/reference/functions/get_search_comments_feed_link/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_search_comments_feed_link/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_search_comments_feed_link/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.5.0](https://developer.wordpress.org/reference/since/2.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_search_comments_feed_link%2F)
before being able to contribute a note or feedback.