函数原型
get_post_type_archive_feed_link( string $post_type, string $feed = ” ): string|false
函数描述
Retrieves the permalink for a post type archive feed.
是否弃用
未弃用
函数参数
-
$post_type
string
Required - Post type.
-
$feed
string
Optional - Feed type. Possible values include
'rss2','atom'.
Default is the value of get_default_feed() .Default:
''
函数返回值
string|false The post type feed permalink. False if the post type does not exist or does not have an archive.
函数位置
File: wp-includes/link-template.php.
函数源码
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 );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 3.1.0 | Introduced. |

