网站优化

网站优化

Products

当前位置:首页 > 网站优化 >

Wordpress转换为html5,WP可以用html5吗

GG网络技术分享 2025-03-18 16:09 0


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 教程

提交需求或反馈

Demand feedback