1、html 添加打印链接
- <a href=“javascript:printme()” target=“_self”>打印</a>
2、js 函数:在你的 wp 中引入下面的 Js,或者放在你的文章页 single.php 或脚部文件 footer.php 底部。
- <script type=“text/javascript”>
- var global_Html = “”;
- function printme() {
- global_Html = document.body.innerHTML;
- document.body.innerHTML = document.getElementById(‘div-main’).innerHTML;
- window.print();
- window.setTimeout(function() {
- document.body.innerHTML = global_Html;
- }, 1500);
- }
- </script>
注意: div-main 是你的页面的主题 div 的 ID,要修改成你主题的 DIV 的 ID。
以上内容整理自@511 遇见