get_post_comments_feed_link()
get_post_comments_feed_link( int $post_id, string $feed…
get_post_comments_feed_link( int $post_id, string $feed = ” )
检索post comments提要的permalink。
Retrieves the permalink for the post comments feed.
检索post comments提要的permalink。
Retrieves the permalink for the post comments feed.
目录锚点:#参数#返回#源码
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $post_id | (int) | 可选 | Post ID。默认值是全局$Post的ID。 |
| $feed | (string) | 可选 | 进给类型。可能的值包括“rss2”、“atom”。Default是get_Default_feed()的值。 |
返回(Return)
(string)给定文章的评论源的永久链接。
源码(Source)
/**
* Retrieve the permalink for the post comments feed.
*
* @since 2.2.0
*
* @param int $post_id Optional. Post ID.
* @param string $feed Optional. Feed type.
* @return string The permalink for the comments feed for the given post.
*/
function get_post_comments_feed_link($post_id = 0, $feed = '') {
$post_id = absint( $post_id );
if ( ! $post_id )
$post_id = get_the_ID();
if ( empty( $feed ) )
$feed = get_default_feed();
if ( '' != get_option('permalink_structure') ) {
if ( 'page' == get_option('show_on_front') && $post_id == get_option('page_on_front') )
$url = _get_page_link( $post_id );
else
$url = get_permalink($post_id);
$url = trailingslashit($url) . 'feed';
if ( $feed != get_default_feed() )
$url .= "/$feed";
$url = user_trailingslashit($url, 'single_feed');
} else {
$type = get_post_field('post_type', $post_id);
if ( 'page' == $type )
$url = add_query_arg( array( 'feed' => $feed, 'page_id' => $post_id ), home_url( '/' ) );
else
$url = add_query_arg( array( 'feed' => $feed, 'p' => $post_id ), home_url( '/' ) );
}
/**
* Filter the post comments feed permalink.
*
* @since 1.5.1
*
* @param string $url Post comments feed permalink.
*/
return apply_filters( 'post_comments_feed_link', $url );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 2.2.0 | wp-includes/link-template.php:670 | 5 | 13 |
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
还没有任何评论,赶紧来占个楼吧!