The html_type_rss() WordPress PHP function displays the HTML type based on the blog setting. The two possible values are either ‘xhtml’ or ‘html’.
Usage
To use the html_type_rss() function, simply call it where you want to display the HTML type. The function doesn’t require any parameters. Here’s an example:
echo html_type_rss();
This will output either ‘xhtml’ or ‘html’, depending on your blog settings.
Parameters
- The html_type_rss() function does not take any parameters.
More information
See WordPress Developer Resources: html_type_rss()
The html_type_rss() function is used primarily in WordPress themes or plugins. It does not have a deprecated version and is available in all WordPress versions.
Examples
Example 1 – Display HTML Type
If you want to display the HTML type of your blog, use the following code:
echo 'The HTML type of this blog is: '; echo html_type_rss();
Example 2 – Conditional Display
You can also use the function in a conditional statement to display specific content based on the HTML type.
$html_type = html_type_rss(); if($html_type == 'xhtml') { echo 'This blog uses XHTML.'; } else { echo 'This blog uses HTML.'; }
Example 3 – In an RSS Feed
The function can be used in an RSS feed to specify the type of content that will be served.
echo '<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/" xmlns:snf="http://www.smartnews.be/snf" xmlns:map="http://www.map.gs/1.0" xmlns:article="http://schema.org/Article" xmlns:rating="http://schema.org/Rating" xmlns:blog="http://vocab.ampproject.org/amp#" xmlns:news="http://schema.org/NewsArticle" ' . html_type_rss() . '>';
Example 4 – In the HTML Tag
The function can be used within the HTML tag itself to specify the type of document being served.
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD ' . html_type_rss() . ' 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
Example 5 – In a Function
You can use this function in your own custom function to get the HTML type.
function get_blog_html_type() { return html_type_rss(); } echo 'The HTML type of this blog is: ' . get_blog_html_type();
This will also output either ‘xhtml’ or ‘html’, depending on your blog settings.