^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云2核2g仅需86元/年

wordpress函数get_post_comments_feed_link()用法示例

get_post_comments_feed_link( int $post_id,  string $feed = '' )

Retrieves the permalink for the post comments feed.


描述


参数

$post_id

(int)
(Optional)
Post ID. Default is the ID of the global $post.

新用户2核2g仅需86元/年    领取1153套模板    免费cdn流量包    ¥3188礼包

$feed

(string)
(Optional)
Feed type.

Default value: ''


返回值

(string) The permalink for the comments feed for the given post.


源代码

File: wp-includes/link-template.php

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();

	$post = get_post( $post_id );
	$unattached = 'attachment' === $post->post_type && 0 === (int) $post->post_parent;

	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);

		if ( $unattached ) {
			$url =  home_url( '/feed/' );
			if ( $feed !== get_default_feed() ) {
				$url .= "$feed/";
			}
			$url = add_query_arg( 'attachment_id', $post_id, $url );
		} else {
			$url = trailingslashit($url) . 'feed';
			if ( $feed != get_default_feed() )
				$url .= "/$feed";
			$url = user_trailingslashit($url, 'single_feed');
		}
	} else {
		if ( $unattached ) {
			$url = add_query_arg( array( 'feed' => $feed, 'attachment_id' => $post_id ), home_url( '/' ) );
		} elseif ( 'page' == $post->post_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( '/' ) );
		}
	}

	/**
	 * Filters the post comments feed permalink.
	 *
	 * @since 1.5.1
	 *
	 * @param string $url Post comments feed permalink.
	 */
	return apply_filters( 'post_comments_feed_link', $url );
}

更新日志

Version 描述
2.2.0 Introduced.

相关函数

Uses

  • wp-includes/formatting.php:
    trailingslashit()
  • wp-includes/functions.php:
    absint()
  • wp-includes/functions.php:
    add_query_arg()
  • wp-includes/link-template.php:
    home_url()
  • wp-includes/link-template.php:
    post_comments_feed_link
  • wp-includes/link-template.php:
    _get_page_link()
  • wp-includes/link-template.php:
    get_permalink()
  • wp-includes/link-template.php:
    user_trailingslashit()
  • wp-includes/plugin.php:
    apply_filters()
  • wp-includes/feed.php:
    get_default_feed()
  • wp-includes/option.php:
    get_option()
  • wp-includes/post-template.php:
    get_the_ID()
  • wp-includes/post.php:
    get_post()
  • Show 8 more uses


Used By

  • wp-includes/general-template.php:
    feed_links_extra()
  • wp-includes/deprecated.php:
    comments_rss()
  • wp-includes/link-template.php:
    post_comments_feed_link()
  • wp-includes/canonical.php:
    redirect_canonical()
  • wp-includes/canonical.php:
    redirect_guess_404_permalink()

让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈