Create code highlighter without plugin by use “google-code-prettify” in WordPress

1. Put the following code to your theme footer.php within <body></body> tag:

* Or you could put the code to header tag (header.php) if you wanna load it earlier than this.

 

2. When you wanna highlight a code, switch to text view in WordPress editor, and put your code snippets inside of a “pre” tag: <pre class=”prettyprint”>//code here</pre>

Or a “code” tag: <code class=”prettyprint”>//code here</code>

 

The result should look like this(Notice that the line number appears in every fifth line by default):

Create code highlighter without plugin by use “google-code-prettify” in WordPress

 

</catmee> 文章全部原创、谢绝转载,作者「BianLei」,如果喜欢欢迎分享链接,相关内容参见本站版权声明
如果您觉得本站的存在对您多少有所帮助,可以用手机支付宝扫一扫以下二维码支付任意金额作为支持:支付宝
本站相关:QQ空间 | Facebook
Tagged . Bookmark the permalink.

2 Ways to notify WordPress comments author upon their replies without plugins
2 Ways to notify WordPress comments author upon their replies without plugins

How to Cloak Affiliate Links in WordPress without Plugin
How to Cloak Affiliate Links in WordPress without Plugin

China Street Style 1 | Harbin Street Style
China Street Style 1 | Harbin Street Style

Small Letter forever (3) Dream
Small Letter forever (3) Dream

松花江滨州铁路桥(The Songhua River Binzhou railway bridge)
松花江滨州铁路桥(The Songhua River Binzhou railway bridge)

Comment Anonymously? No Problem! | 可以匿名评论了我会说?

Fill up Email address to subscribe reply and display your avatar from Gravatar (If any)
填写邮箱即可显示您在Gravatar的头像