feed_content_type

函数
feed_content_type ( $type = '' )
参数
  • (string) $type Type of feed. Possible values include 'rss', rss2', 'atom', and 'rdf'.
    Required:
    Default: (empty)
定义位置
相关方法
get_comment_typecomment_typethe_content_feedget_the_content_feedthe_content
引入
2.8.0
弃用
-

feed_content_type。这个过滤器用于修改WordPress feed的内容类型。

返回指定feed类型的内容类型。

function feed_content_type( $type = '' ) {
	if ( empty( $type ) ) {
		$type = get_default_feed();
	}

	$types = array(
		'rss'      => 'application/rss+xml',
		'rss2'     => 'application/rss+xml',
		'rss-http' => 'text/xml',
		'atom'     => 'application/atom+xml',
		'rdf'      => 'application/rdf+xml',
	);

	$content_type = ( ! empty( $types[ $type ] ) ) ? $types[ $type ] : 'application/octet-stream';

	/**
	 * Filters the content type for a specific feed type.
	 *
	 * @since 2.8.0
	 *
	 * @param string $content_type Content type indicating the type of data that a feed contains.
	 * @param string $type         Type of feed. Possible values include 'rss', rss2', 'atom', and 'rdf'.
	 */
	return apply_filters( 'feed_content_type', $content_type, $type );
}

常见问题

FAQs
查看更多 >