get_feed_link() – Retrieves the permalink for the feed type.

You appear to be a bot. Output may be restricted

Description

Retrieves the permalink for the feed type.

Usage

$string = get_feed_link( $feed );

Parameters

$feed
( string ) optional – Optional. Feed type. Possible values include 'rss2', 'atom'. Default is the value of get_default_feed().

Returns

string The feed permalink.

Source

File name: wordpress/wp-includes/link-template.php
Lines:

1 to 41 of 41
function get_feed_link( $feed = '' ) {
  global $wp_rewrite;

  $permalink = $wp_rewrite->get_feed_permastruct();

  if ( $permalink ) {
    if ( false !== strpos( $feed, 'comments_' ) ) {
      $feed      = str_replace( 'comments_', '', $feed );
      $permalink = $wp_rewrite->get_comment_feed_permastruct();
    }

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

    $permalink = str_replace( '%feed%', $feed, $permalink );
    $permalink = preg_replace( '#/+#', '/', "/$permalink" );
    $output    = home_url( user_trailingslashit( $permalink, 'feed' ) );
  } else {
    if ( empty( $feed ) ) {
      $feed = get_default_feed();
    }

    if ( false !== strpos( $feed, 'comments_' ) ) {
      $feed = str_replace( 'comments_', 'comments-', $feed );
    }

    $output = home_url( "?feed={$feed}" );
  }

  
/**
 * Filters the feed type permalink.
 *
 * @since 1.5.0
 *
 * @param string $output The feed permalink.
 * @param string $feed   The feed type. Possible values include 'rss2', 'atom',
 *                       or an empty string for the default feed type.
 */
  return apply_filters( 'feed_link', $output, $feed );
}
 

 View on GitHub View on Trac