feed_links

函式
feed_links ( $args = array() )
引數
  • (array) $args Optional arguments.
    Required:
    Default: array()
定義位置
相關方法
the_feed_linkget_feed_linkfeed_links_extraedit_linkget_links
引入
2.8.0
棄用
-

feed_links – 這個函式輸出到當前網站上的文章和評論的RSS提要的連結。它接受一個用於定製輸出的選項陣列,例如feed型別、連結文字和圖示。

顯示到一般feed的連結。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function feed_links( $args = array() ) {
if ( ! current_theme_supports( 'automatic-feed-links' ) ) {
return;
}
$defaults = array(
/* translators: Separator between blog name and feed type in feed links. */
'separator' => _x( '»', 'feed link' ),
/* translators: 1: Blog title, 2: Separator (raquo). */
'feedtitle' => __( '%1$s %2$s Feed' ),
/* translators: 1: Blog title, 2: Separator (raquo). */
'comstitle' => __( '%1$s %2$s Comments Feed' ),
);
$args = wp_parse_args( $args, $defaults );
/**
* Filters whether to display the posts feed link.
*
* @since 4.4.0
*
* @param bool $show Whether to display the posts feed link. Default true.
*/
if ( apply_filters( 'feed_links_show_posts_feed', true ) ) {
printf(
'<link rel="alternate" type="%s" title="%s" href="%s" />' . "n",
feed_content_type(),
esc_attr( sprintf( $args['feedtitle'], get_bloginfo( 'name' ), $args['separator'] ) ),
esc_url( get_feed_link() )
);
}
/**
* Filters whether to display the comments feed link.
*
* @since 4.4.0
*
* @param bool $show Whether to display the comments feed link. Default true.
*/
if ( apply_filters( 'feed_links_show_comments_feed', true ) ) {
printf(
'<link rel="alternate" type="%s" title="%s" href="%s" />' . "n",
feed_content_type(),
esc_attr( sprintf( $args['comstitle'], get_bloginfo( 'name' ), $args['separator'] ) ),
esc_url( get_feed_link( 'comments_' . get_default_feed() ) )
);
}
}
function feed_links( $args = array() ) { if ( ! current_theme_supports( 'automatic-feed-links' ) ) { return; } $defaults = array( /* translators: Separator between blog name and feed type in feed links. */ 'separator' => _x( '&raquo;', 'feed link' ), /* translators: 1: Blog title, 2: Separator (raquo). */ 'feedtitle' => __( '%1$s %2$s Feed' ), /* translators: 1: Blog title, 2: Separator (raquo). */ 'comstitle' => __( '%1$s %2$s Comments Feed' ), ); $args = wp_parse_args( $args, $defaults ); /** * Filters whether to display the posts feed link. * * @since 4.4.0 * * @param bool $show Whether to display the posts feed link. Default true. */ if ( apply_filters( 'feed_links_show_posts_feed', true ) ) { printf( '<link rel="alternate" type="%s" title="%s" href="%s" />' . "n", feed_content_type(), esc_attr( sprintf( $args['feedtitle'], get_bloginfo( 'name' ), $args['separator'] ) ), esc_url( get_feed_link() ) ); } /** * Filters whether to display the comments feed link. * * @since 4.4.0 * * @param bool $show Whether to display the comments feed link. Default true. */ if ( apply_filters( 'feed_links_show_comments_feed', true ) ) { printf( '<link rel="alternate" type="%s" title="%s" href="%s" />' . "n", feed_content_type(), esc_attr( sprintf( $args['comstitle'], get_bloginfo( 'name' ), $args['separator'] ) ), esc_url( get_feed_link( 'comments_' . get_default_feed() ) ) ); } }
function feed_links( $args = array() ) {
	if ( ! current_theme_supports( 'automatic-feed-links' ) ) {
		return;
	}

	$defaults = array(
		/* translators: Separator between blog name and feed type in feed links. */
		'separator' => _x( '&raquo;', 'feed link' ),
		/* translators: 1: Blog title, 2: Separator (raquo). */
		'feedtitle' => __( '%1$s %2$s Feed' ),
		/* translators: 1: Blog title, 2: Separator (raquo). */
		'comstitle' => __( '%1$s %2$s Comments Feed' ),
	);

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

	/**
	 * Filters whether to display the posts feed link.
	 *
	 * @since 4.4.0
	 *
	 * @param bool $show Whether to display the posts feed link. Default true.
	 */
	if ( apply_filters( 'feed_links_show_posts_feed', true ) ) {
		printf(
			'<link rel="alternate" type="%s" title="%s" href="%s" />' . "n",
			feed_content_type(),
			esc_attr( sprintf( $args['feedtitle'], get_bloginfo( 'name' ), $args['separator'] ) ),
			esc_url( get_feed_link() )
		);
	}

	/**
	 * Filters whether to display the comments feed link.
	 *
	 * @since 4.4.0
	 *
	 * @param bool $show Whether to display the comments feed link. Default true.
	 */
	if ( apply_filters( 'feed_links_show_comments_feed', true ) ) {
		printf(
			'<link rel="alternate" type="%s" title="%s" href="%s" />' . "n",
			feed_content_type(),
			esc_attr( sprintf( $args['comstitle'], get_bloginfo( 'name' ), $args['separator'] ) ),
			esc_url( get_feed_link( 'comments_' . get_default_feed() ) )
		);
	}
}

常見問題

FAQs
檢視更多 >