函数文档

html_type_rss()

💡 云策文档标注

概述

html_type_rss() 函数用于根据博客设置显示 HTML 类型,支持 'xhtml' 或 'html' 两种值。

关键要点

  • 函数基于 get_bloginfo('html_type') 获取当前站点的 HTML 类型
  • 通过 str_contains() 检查类型字符串,标准化输出为 'xhtml' 或 'html'
  • 直接使用 echo 输出结果,适用于 RSS 或相关模板中

代码示例

function html_type_rss() {
	$type = get_bloginfo( 'html_type' );
	if ( str_contains( $type, 'xhtml' ) ) {
		$type = 'xhtml';
	} else {
		$type = 'html';
	}
	echo $type;
}

注意事项

  • 函数自 WordPress 2.2.0 版本引入,无后续变更记录
  • 相关函数 get_bloginfo() 可用于检索更多站点信息
  • 输出值直接用于前端,确保与主题或插件兼容

📄 原文内容

Displays the HTML type based on the blog setting.

Description

The two possible values are either ‘xhtml’ or ‘html’.

Source

function html_type_rss() {
	$type = get_bloginfo( 'html_type' );
	if ( str_contains( $type, 'xhtml' ) ) {
		$type = 'xhtml';
	} else {
		$type = 'html';
	}
	echo $type;
}

Changelog

Version Description
2.2.0 Introduced.