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

wordpress函数feed_links_extra()用法示例

feed_links_extra( array $args = array() )

Display the links to the extra feeds such as category feeds.


描述


参数

$args

(array)
(Optional)
arguments.

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

Default value: array()


源代码

File: wp-includes/general-template.php

function feed_links_extra( $args = array() ) {
	$defaults = array(
		/* translators: Separator between blog name and feed type in feed links */
		'separator'   => _x('»', 'feed link'),
		/* translators: 1: blog name, 2: separator(raquo), 3: post title */
		'singletitle' => __('%1$s %2$s %3$s Comments Feed'),
		/* translators: 1: blog name, 2: separator(raquo), 3: category name */
		'cattitle'    => __('%1$s %2$s %3$s Category Feed'),
		/* translators: 1: blog name, 2: separator(raquo), 3: tag name */
		'tagtitle'    => __('%1$s %2$s %3$s Tag Feed'),
		/* translators: 1: blog name, 2: separator(raquo), 3: term name, 4: taxonomy singular name */
		'taxtitle'    => __('%1$s %2$s %3$s %4$s Feed'),
		/* translators: 1: blog name, 2: separator(raquo), 3: author name  */
		'authortitle' => __('%1$s %2$s Posts by %3$s Feed'),
		/* translators: 1: blog name, 2: separator(raquo), 3: search phrase */
		'searchtitle' => __('%1$s %2$s Search Results for “%3$s” Feed'),
		/* translators: 1: blog name, 2: separator(raquo), 3: post type name */
		'posttypetitle' => __('%1$s %2$s %3$s Feed'),
	);

	$args = wp_parse_args( $args, $defaults );

	if ( is_singular() ) {
		$id = 0;
		$post = get_post( $id );

		if ( comments_open() || pings_open() || $post->comment_count > 0 ) {
			$title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], the_title_attribute( array( 'echo' => false ) ) );
			$href = get_post_comments_feed_link( $post->ID );
		}
	} elseif ( is_post_type_archive() ) {
		$post_type = get_query_var( 'post_type' );
		if ( is_array( $post_type ) )
			$post_type = reset( $post_type );

		$post_type_obj = get_post_type_object( $post_type );
		$title = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], $post_type_obj->labels->name );
		$href = get_post_type_archive_feed_link( $post_type_obj->name );
	} elseif ( is_category() ) {
		$term = get_queried_object();

		if ( $term ) {
			$title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name );
			$href = get_category_feed_link( $term->term_id );
		}
	} elseif ( is_tag() ) {
		$term = get_queried_object();

		if ( $term ) {
			$title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name );
			$href = get_tag_feed_link( $term->term_id );
		}
	} elseif ( is_tax() ) {
 		$term = get_queried_object();
 		$tax = get_taxonomy( $term->taxonomy );
 		$title = sprintf( $args['taxtitle'], get_bloginfo('name'), $args['separator'], $term->name, $tax->labels->singular_name );
 		$href = get_term_feed_link( $term->term_id, $term->taxonomy );
	} elseif ( is_author() ) {
		$author_id = intval( get_query_var('author') );

		$title = sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) );
		$href = get_author_feed_link( $author_id );
	} elseif ( is_search() ) {
		$title = sprintf( $args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query( false ) );
		$href = get_search_feed_link();
	} elseif ( is_post_type_archive() ) {
		$title = sprintf( $args['posttypetitle'], get_bloginfo('name'), $args['separator'], post_type_archive_title( '', false ) );
		$post_type_obj = get_queried_object();
		if ( $post_type_obj )
			$href = get_post_type_archive_feed_link( $post_type_obj->name );
	}

	if ( isset($title) && isset($href) )
		echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $title ) . '" href="' . esc_url( $href ) . '" />' . "\n";
}

更新日志

Version 描述
2.8.0 Introduced.

相关函数

Uses

  • wp-includes/l10n.php:
    _x()
  • wp-includes/l10n.php:
    __()
  • wp-includes/formatting.php:
    esc_attr()
  • wp-includes/formatting.php:
    esc_url()
  • wp-includes/general-template.php:
    get_search_query()
  • wp-includes/general-template.php:
    get_bloginfo()
  • wp-includes/general-template.php:
    post_type_archive_title()
  • wp-includes/query.php:
    is_singular()
  • wp-includes/query.php:
    is_search()
  • wp-includes/query.php:
    is_category()
  • wp-includes/query.php:
    is_tag()
  • wp-includes/query.php:
    is_tax()
  • wp-includes/query.php:
    is_author()
  • wp-includes/query.php:
    is_post_type_archive()
  • wp-includes/query.php:
    get_query_var()
  • wp-includes/query.php:
    get_queried_object()
  • wp-includes/functions.php:
    wp_parse_args()
  • wp-includes/taxonomy.php:
    get_taxonomy()
  • wp-includes/link-template.php:
    get_post_type_archive_feed_link()
  • wp-includes/link-template.php:
    get_tag_feed_link()
  • wp-includes/link-template.php:
    get_term_feed_link()
  • wp-includes/link-template.php:
    get_search_feed_link()
  • wp-includes/link-template.php:
    get_post_comments_feed_link()
  • wp-includes/link-template.php:
    get_category_feed_link()
  • wp-includes/link-template.php:
    get_author_feed_link()
  • wp-includes/feed.php:
    feed_content_type()
  • wp-includes/post-template.php:
    the_title_attribute()
  • wp-includes/post.php:
    get_post()
  • wp-includes/post.php:
    get_post_type_object()
  • wp-includes/author-template.php:
    get_the_author_meta()
  • wp-includes/comment-template.php:
    comments_open()
  • wp-includes/comment-template.php:
    pings_open()
  • Show 27 more uses


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

热门推荐

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

反馈