Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Difference between revisions of "Theme Markup"

m (added link to Japanese translation)
(Adding Theme Support: add teh missing meta style and script.)
 
(13 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
{{Languages|
 
{{Languages|
{{en|Semantic Markup}}
+
{{en|Theme Markup}}
 
{{ja|Semantic Markup}}
 
{{ja|Semantic Markup}}
 
}}
 
}}
'''Semantic Markup''' is a [[Theme Features|theme feature]], first introduced in [[Version 3.6]]. This feature allows themes to explicitly choose to apply HTML5 markup for search forms, comment forms, and comment lists.
+
'''Theme Markup''' is a [[Theme Features|theme feature]], first introduced in [[Version 3.6]]. This feature allows themes to explicitly choose to apply HTML5 markup for search forms, comment forms, comment lists, gallery and caption.
   
 
== Adding Theme Support ==
 
== Adding Theme Support ==
   
Since [[Version 3.6]], themes should use [[Function_Reference/add_theme_support|add_theme_support()]] in the [[Theme_Development#Functions_File|functions.php]] file in order to support semantic markup, like so:
+
Since [[Version 3.6]], themes should use [[Function_Reference/add_theme_support|add_theme_support()]] in the [[Theme_Development#Functions_File|functions.php]] file in order to support theme markup, like so:
   
<pre>add_theme_support( 'html5' );</pre>
+
<pre>add_theme_support( 'html5', array( 'gallery' ) );</pre>
   
  +
The second parameter accepts one or more values indicating which HTML5 features to support. Support for '<tt>search-form</tt>', '<tt>comment-form</tt>' and '<tt>comment-list</tt>' were added in [[Version 3.6]]. Support for '<tt>gallery</tt>' and '<tt>caption</tt>' were added in [[Version 3.9]].:
Note that you can pass in various arguments:
 
   
 
<pre>
 
<pre>
Line 18: Line 18:
 
'comment-form',
 
'comment-form',
 
'comment-list',
 
'comment-list',
  +
'gallery',
  +
'caption',
  +
  +
'meta',
  +
'style',
  +
'script',
 
);
 
);
 
add_theme_support( 'html5', $args );
 
add_theme_support( 'html5', $args );
 
</pre>
 
</pre>
  +
  +
The second argument is a required parameter for forward compatibility reasons. Namely, so a theme won't break in newer versions of WordPress that have HTML5 features not supported by an older theme.
  +
  +
== Changelog ==
  +
  +
* [[Version 3.6|3.6]]: Introduced with '<tt>search-form</tt>', '<tt>comment-form</tt>' and '<tt>comment-list</tt>' support
  +
* [[Version 3.9|3.9]]: Added '<tt>gallery</tt>' and '<tt>caption</tt>' support
  +
  +
== Notes ==
  +
  +
* '''Galleries & Captions:''' As of version 3.9 WordPress uses <code><figure></code> and <code><figcaption></code> elements, instead of the generic definition list markup to output [[The WordPress Gallery|galleries]]. More on this in the [http://make.wordpress.org/core/2014/04/15/html5-galleries-captions-in-wordpress-3-9/ Make WordPress Core article].
   
 
== Resources ==
 
== Resources ==

Latest revision as of 15:33, 14 December 2022

Theme Markup is a theme feature, first introduced in Version 3.6. This feature allows themes to explicitly choose to apply HTML5 markup for search forms, comment forms, comment lists, gallery and caption.

Adding Theme Support

Since Version 3.6, themes should use add_theme_support() in the functions.php file in order to support theme markup, like so:

add_theme_support( 'html5', array( 'gallery' ) );

The second parameter accepts one or more values indicating which HTML5 features to support. Support for 'search-form', 'comment-form' and 'comment-list' were added in Version 3.6. Support for 'gallery' and 'caption' were added in Version 3.9.:

$args = array(
	'search-form',
	'comment-form',
	'comment-list',
	'gallery',
	'caption',

	'meta',
	'style',
	'script',
);
add_theme_support( 'html5', $args );

The second argument is a required parameter for forward compatibility reasons. Namely, so a theme won't break in newer versions of WordPress that have HTML5 features not supported by an older theme.

Changelog

  • 3.6: Introduced with 'search-form', 'comment-form' and 'comment-list' support
  • 3.9: Added 'gallery' and 'caption' support

Notes

  • Galleries & Captions: As of version 3.9 WordPress uses <figure> and <figcaption> elements, instead of the generic definition list markup to output galleries. More on this in the Make WordPress Core article.

Resources

Related

Theme Support: add_theme_support(), remove_theme_support(), current_theme_supports()
Theme Features: sidebar, menus, post-formats, title-tag, custom-background, custom-header, custom-logo, post-thumbnails, automatic-feed-links, html5, editor-style, content_width