### [wordpress可以用html5吗](https://www.prosaas.cn/article/9247)
**Published:** 2019-07-26T02:17:44
**Author:** 5201314
**Excerpt:** wordpress可以用html5吗wordpress是可以用html5的,可以为WordPress开启 HT…
****
**wordpress可以用html5吗**
wordpress是可以用html5的,可以为WordPress开启 HTML5 支持。WordPress 也可以通过在 header.php 文件添加这段代码的方法实现。或者使用 functions.php 文件也可以:
找到当前主题对应的 functions.php 文件,并添加如下代码:
function add\_ie\_html5\_shim () {
echo '';
}
add\_action('wp\_head', 'add\_ie\_html5\_shim');
原理是通过 header.php 文件中的 wp\_head() 函数强行插入。
**wordpress调用html5文件**
就WP核心来说,只需要在下面的HOOK
after\_setup\_theme
的函数内添加如下代码:
/\*
\* Switch default core markup for search form, comment form, and comments
\* to output valid HTML5.
\*/
add\_theme\_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
) );
如果没有找到挂到上面HOOK的函数,需要在functions.php中添加:
add\_action( 'after\_setup\_theme', 'suoling\_net\_after\_theme\_setup' );
function suoling\_net\_after\_theme\_setup(){
/\*
\* Switch default core markup for search form, comment form, and comments
\* to output valid HTML5.
\*/
add\_theme\_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
) );
}
插件的HTML输出一般都是符合HTML5标准的;此外,就是主题对HTML5的支持了,这个需要自行修改,没有什么便捷的方法。
更多WordPress技术文章,请访问WordPress教程栏目!
以上就是wordpress可以用html5吗的详细内容,更多请关注知企PROSAAS其它相关文章!
**Tags:** html, html5, php, WordPress
**Categories:** WordPress
---