get_post_type_archive_feed_link

The timeline below displays how wordpress function get_post_type_archive_feed_link has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.6

/**
 * Retrieves the permalink for a post type archive feed.
 *
 * @since 3.1.0
 *
 * @param string $post_type Post type.
 * @param string $feed      Optional. Feed type. Possible values include 'rss2', 'atom'.
 *                          Default is the value of get_default_feed().
 * @return string|false The post type feed permalink. False if the post type
 *                      does not exist or does not have an archive.
 */
function get_post_type_archive_feed_link($post_type, $feed = '')
{
    $default_feed = get_default_feed();
    if (empty($feed)) {
        $feed = $default_feed;
    }
    $link = get_post_type_archive_link($post_type);
    if (!$link) {
        return false;
    }
    $post_type_obj = get_post_type_object($post_type);
    if (get_option('permalink_structure') && is_array($post_type_obj->rewrite) && $post_type_obj->rewrite['feeds']) {
        $link = trailingslashit($link);
        $link .= 'feed/';
        if ($feed != $default_feed) {
            $link .= "{$feed}/";
        }
    } else {
        $link = add_query_arg('feed', $feed, $link);
    }
    /**
     * Filters the post type archive feed link.
     *
     * @since 3.1.0
     *
     * @param string $link The post type archive feed link.
     * @param string $feed Feed type. Possible values include 'rss2', 'atom'.
     */
    return apply_filters('post_type_archive_feed_link', $link, $feed);
}

WordPress Version: 5.3

/**
 * Retrieves the permalink for a post type archive feed.
 *
 * @since 3.1.0
 *
 * @param string $post_type Post type
 * @param string $feed      Optional. Feed type. Possible values include 'rss2', 'atom'.
 *                          Default is the value of get_default_feed().
 * @return string|false The post type feed permalink.
 */
function get_post_type_archive_feed_link($post_type, $feed = '')
{
    $default_feed = get_default_feed();
    if (empty($feed)) {
        $feed = $default_feed;
    }
    $link = get_post_type_archive_link($post_type);
    if (!$link) {
        return false;
    }
    $post_type_obj = get_post_type_object($post_type);
    if (get_option('permalink_structure') && is_array($post_type_obj->rewrite) && $post_type_obj->rewrite['feeds']) {
        $link = trailingslashit($link);
        $link .= 'feed/';
        if ($feed != $default_feed) {
            $link .= "{$feed}/";
        }
    } else {
        $link = add_query_arg('feed', $feed, $link);
    }
    /**
     * Filters the post type archive feed link.
     *
     * @since 3.1.0
     *
     * @param string $link The post type archive feed link.
     * @param string $feed Feed type. Possible values include 'rss2', 'atom'.
     */
    return apply_filters('post_type_archive_feed_link', $link, $feed);
}

WordPress Version: 4.6

/**
 * Retrieves the permalink for a post type archive feed.
 *
 * @since 3.1.0
 *
 * @param string $post_type Post type
 * @param string $feed      Optional. Feed type. Default empty.
 * @return string|false The post type feed permalink.
 */
function get_post_type_archive_feed_link($post_type, $feed = '')
{
    $default_feed = get_default_feed();
    if (empty($feed)) {
        $feed = $default_feed;
    }
    if (!$link = get_post_type_archive_link($post_type)) {
        return false;
    }
    $post_type_obj = get_post_type_object($post_type);
    if (get_option('permalink_structure') && is_array($post_type_obj->rewrite) && $post_type_obj->rewrite['feeds']) {
        $link = trailingslashit($link);
        $link .= 'feed/';
        if ($feed != $default_feed) {
            $link .= "{$feed}/";
        }
    } else {
        $link = add_query_arg('feed', $feed, $link);
    }
    /**
     * Filters the post type archive feed link.
     *
     * @since 3.1.0
     *
     * @param string $link The post type archive feed link.
     * @param string $feed Feed type.
     */
    return apply_filters('post_type_archive_feed_link', $link, $feed);
}

WordPress Version: 4.3

/**
 * Retrieve the permalink for a post type archive feed.
 *
 * @since 3.1.0
 *
 * @param string $post_type Post type
 * @param string $feed      Optional. Feed type
 * @return string|false The post type feed permalink.
 */
function get_post_type_archive_feed_link($post_type, $feed = '')
{
    $default_feed = get_default_feed();
    if (empty($feed)) {
        $feed = $default_feed;
    }
    if (!$link = get_post_type_archive_link($post_type)) {
        return false;
    }
    $post_type_obj = get_post_type_object($post_type);
    if (get_option('permalink_structure') && is_array($post_type_obj->rewrite) && $post_type_obj->rewrite['feeds']) {
        $link = trailingslashit($link);
        $link .= 'feed/';
        if ($feed != $default_feed) {
            $link .= "{$feed}/";
        }
    } else {
        $link = add_query_arg('feed', $feed, $link);
    }
    /**
     * Filter the post type archive feed link.
     *
     * @since 3.1.0
     *
     * @param string $link The post type archive feed link.
     * @param string $feed Feed type.
     */
    return apply_filters('post_type_archive_feed_link', $link, $feed);
}

WordPress Version: 4.1

/**
 * Retrieve the permalink for a post type archive feed.
 *
 * @since 3.1.0
 *
 * @param string $post_type Post type
 * @param string $feed Optional. Feed type
 * @return string The post type feed permalink.
 */
function get_post_type_archive_feed_link($post_type, $feed = '')
{
    $default_feed = get_default_feed();
    if (empty($feed)) {
        $feed = $default_feed;
    }
    if (!$link = get_post_type_archive_link($post_type)) {
        return false;
    }
    $post_type_obj = get_post_type_object($post_type);
    if (get_option('permalink_structure') && is_array($post_type_obj->rewrite) && $post_type_obj->rewrite['feeds']) {
        $link = trailingslashit($link);
        $link .= 'feed/';
        if ($feed != $default_feed) {
            $link .= "{$feed}/";
        }
    } else {
        $link = add_query_arg('feed', $feed, $link);
    }
    /**
     * Filter the post type archive feed link.
     *
     * @since 3.1.0
     *
     * @param string $link The post type archive feed link.
     * @param string $feed Feed type.
     */
    return apply_filters('post_type_archive_feed_link', $link, $feed);
}

WordPress Version: 3.9

/**
 * Retrieve the permalink for a post type archive feed.
 *
 * @since 3.1.0
 *
 * @param string $post_type Post type
 * @param string $feed Optional. Feed type
 * @return string
 */
function get_post_type_archive_feed_link($post_type, $feed = '')
{
    $default_feed = get_default_feed();
    if (empty($feed)) {
        $feed = $default_feed;
    }
    if (!$link = get_post_type_archive_link($post_type)) {
        return false;
    }
    $post_type_obj = get_post_type_object($post_type);
    if (get_option('permalink_structure') && is_array($post_type_obj->rewrite) && $post_type_obj->rewrite['feeds']) {
        $link = trailingslashit($link);
        $link .= 'feed/';
        if ($feed != $default_feed) {
            $link .= "{$feed}/";
        }
    } else {
        $link = add_query_arg('feed', $feed, $link);
    }
    /**
     * Filter the post type archive feed link.
     *
     * @since 3.1.0
     *
     * @param string $link The post type archive feed link.
     * @param string $feed Feed type.
     */
    return apply_filters('post_type_archive_feed_link', $link, $feed);
}

WordPress Version: 3.7

/**
 * Retrieve the permalink for a post type archive feed.
 *
 * @since 3.1.0
 *
 * @param string $post_type Post type
 * @param string $feed Optional. Feed type
 * @return string
 */
function get_post_type_archive_feed_link($post_type, $feed = '')
{
    $default_feed = get_default_feed();
    if (empty($feed)) {
        $feed = $default_feed;
    }
    if (!$link = get_post_type_archive_link($post_type)) {
        return false;
    }
    $post_type_obj = get_post_type_object($post_type);
    if (get_option('permalink_structure') && is_array($post_type_obj->rewrite) && $post_type_obj->rewrite['feeds']) {
        $link = trailingslashit($link);
        $link .= 'feed/';
        if ($feed != $default_feed) {
            $link .= "{$feed}/";
        }
    } else {
        $link = add_query_arg('feed', $feed, $link);
    }
    return apply_filters('post_type_archive_feed_link', $link, $feed);
}