{"id":2691,"date":"2018-04-23T19:00:34","date_gmt":"2018-04-23T19:00:34","guid":{"rendered":"http:\/\/reseller-hosting-themes.com\/wordpress\/?p=2691"},"modified":"2018-06-13T11:42:52","modified_gmt":"2018-06-13T11:42:52","slug":"best-code-snippets-wordpress-plugins","status":"publish","type":"post","link":"https:\/\/reseller-hosting-themes.com\/wordpress\/best-code-snippets-wordpress-plugins\/","title":{"rendered":"The Best WordPress Plugins for Code Snippets (2018)"},"content":{"rendered":"<p><img decoding=\"async\" loading=\"lazy\" class=\"alignright wp-image-2824 size-medium\" src=\"https:\/\/reseller-hosting-themes.com\/wordpress\/wp-content\/uploads\/2018\/04\/best-code-snippets-plugins-for-wordpress-300x225.png\" alt=\"The Best WordPress Plugins for Displaying Code Snippets (2018)\" width=\"300\" height=\"225\" srcset=\"https:\/\/reseller-hosting-themes.com\/wordpress\/wp-content\/uploads\/2018\/04\/best-code-snippets-plugins-for-wordpress-300x225.png 300w, https:\/\/reseller-hosting-themes.com\/wordpress\/wp-content\/uploads\/2018\/04\/best-code-snippets-plugins-for-wordpress.png 640w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/>You don&#8217;t have to be a full-time programmer to learn how to display code on your WordPress site.<\/p>\n<p>Maybe you\u2019ve just found out a good tutorial that you want to share? Maybe you\u2019ve written about different tips and tricks, some of which require minor code modifications?<\/p>\n<p>Or maybe you really <em>are<\/em> a programmer who wants to highlight or showcase a particular piece of code?<\/p>\n<p>The problem with all these cases is that displaying raw code in a WordPress post or page can be quite difficult.<\/p>\n<p>And that is why we\u2019ve surfed the Internet and found out the best plugins for displaying code snippets.<\/p>\n<p>With their help, you will be able to effortlessly display all sorts of code anywhere on your WordPress site.<\/p>\n<h2>Snipplr<\/h2>\n<p>Snipplr is more of a platform than a plugin. You can post a piece of code on their website and later on embed it in your page or post, much in the same way you embed a tweet or an Instagram post.<\/p>\n<p>The downside of this approach is that the code snippets are not actually available on your site and if something happens to Snipplr, they will all be gone.<\/p>\n<p>There is also an unofficial plugin that allows you to embed code from Snipplr based on the snippet ID. However, this plugin was last updated 8 years ago, so you are probably better off just using the embed code.<\/p>\n<h2>CodeColorer<\/h2>\n<p>CodeColorer is, as its name suggests, a plugin that allows you to not only post snippets of code on your website, but also to highlight them properly.<\/p>\n<p>It&#8217;s based on the GeSHi library and currently supports more than 250 different programming languages.<\/p>\n<p>It also allows you to limit the box size. This means that if you post a particularly large snippet, instead of additional height atop the content on your web page, a handy mini-scroll bar will appear.<\/p>\n<p>On top of that, you can also add inline code snippets if you just want to post a specific line or a single comment. They too will appear highlighted.<\/p>\n<p>And actually adding code to your site is simple. All you have to do is add the simple shorttag [cc lang=&#8221;lang&#8221;] [\/cc], where &#8220;lang&#8221; will be replaced with the programming language you are using.<\/p>\n<p>A quick example with PHP code will look like this:<\/p>\n<blockquote>\n<pre><code>[cc lang=\"php\"]\r\n\/\/ your actual code\r\n[\/cc]<\/code><\/pre>\n<\/blockquote>\n<p>CodeColorer also offers 9 color themes. You will be able to customize each one of them via CSS.<\/p>\n<h2>SyntaxHighlighter Evolved<\/h2>\n<p>This is one of the most popular plugins for displaying code snippets and for good reason.<\/p>\n<p>In order to work, it only requires that you put two simple tags at the beginning &#8211; [lang], and at the end of the given code snippet &#8211; [\/lang], where &#8220;lang&#8221; is the name of the programming language being used.<\/p>\n<p>Here is an example:<\/p>\n<blockquote><p>\n[ php]<br \/>\n\/\/ your actual code<br \/>\n[\/ php]\n<\/p><\/blockquote>\n<p>And that&#8217;s it. Your code will now show up and will be properly highlighted.<\/p>\n<p>For more advanced users, there is a whole host of snippet customization options.<\/p>\n<p>What makes it different from other plugins is the underlying technology. Instead of the GeSHi library, SyntaxHighlighter Evolved uses the SyntaxHighlighter JavaScript library.<\/p>\n<p>This script library is also used by default on WordPress.com &#8211; the WordPress creators\u2019 free blogging platform.<\/p>\n<p>SyntaxHighlighter Evolved comes with 7 themes. You will be able to modify them additionally or to even build your own theme using CSS classes.<\/p>\n<h2>WP Code Highlight.js<\/h2>\n<p>WP Code Highlight.js uses the same library as SyntaxHighlighter Evolved does. However, there is one big difference &#8211; you don&#8217;t have to specify the programming language. All you need to do is put your code between the\u00a0&lt;pre&gt;&lt;code&gt; and &lt;\/pre&gt;&lt;\/code&gt; tags and that&#8217;s it.<\/p>\n<p>The plugin will do all the rest &#8211; it will guess the programming language being used and will apply adequate highlighting.<\/p>\n<p>Another advantage is that WP Code Highlight.js can be hosted both locally and on a CDN. The local hosting option allows you to choose exactly which language packages you need. If you only post PHP and CSS code, you probably won&#8217;t need the C or C# packages.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Looking to showcase some code on your WordPress blog, but wondering what the best tools are? Check our guide on the best WordPress plugins for displaying code snippets.<\/p>\n","protected":false},"author":1,"featured_media":2824,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"_links":{"self":[{"href":"https:\/\/reseller-hosting-themes.com\/wordpress\/wp-json\/wp\/v2\/posts\/2691"}],"collection":[{"href":"https:\/\/reseller-hosting-themes.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/reseller-hosting-themes.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/reseller-hosting-themes.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/reseller-hosting-themes.com\/wordpress\/wp-json\/wp\/v2\/comments?post=2691"}],"version-history":[{"count":22,"href":"https:\/\/reseller-hosting-themes.com\/wordpress\/wp-json\/wp\/v2\/posts\/2691\/revisions"}],"predecessor-version":[{"id":2833,"href":"https:\/\/reseller-hosting-themes.com\/wordpress\/wp-json\/wp\/v2\/posts\/2691\/revisions\/2833"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/reseller-hosting-themes.com\/wordpress\/wp-json\/wp\/v2\/media\/2824"}],"wp:attachment":[{"href":"https:\/\/reseller-hosting-themes.com\/wordpress\/wp-json\/wp\/v2\/media?parent=2691"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/reseller-hosting-themes.com\/wordpress\/wp-json\/wp\/v2\/categories?post=2691"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/reseller-hosting-themes.com\/wordpress\/wp-json\/wp\/v2\/tags?post=2691"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}