WordPress是可以用html5的,可以為WordPress開啟 HTML5 支持。WordPress 也可以通過在 header.php 文件添加這段代碼的方法實現(xiàn)。或者使用 functions.php 文件也可以:
找到當(dāng)前主題對應(yīng)的 functions.php 文件,并添加如下代碼:
function?add_ie_html5_shim?()?{ ????echo?''; } add_action('wp_head',?'add_ie_html5_shim');
原理是通過 header.php 文件中的 wp_head() 函數(shù)強(qiáng)行插入。
wordpress調(diào)用html5文件
立即學(xué)習(xí)“前端免費學(xué)習(xí)筆記(深入)”;
就WP核心來說,只需要在下面的HOOK
after_setup_theme
的函數(shù)內(nèi)添加如下代碼:
/* ?*?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的函數(shù),需要在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標(biāo)準(zhǔn)的;此外,就是主題對HTML5的支持了,這個需要自行修改,沒有什么便捷的方法。
更多WordPress技術(shù)文章,請訪問WordPress教程欄目!
? 版權(quán)聲明
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載。
THE END
喜歡就支持一下吧
相關(guān)推薦