{"id":8103,"date":"2013-04-22T16:13:36","date_gmt":"2013-04-22T21:13:36","guid":{"rendered":"http:\/\/www.jbaker.info\/?p=8103"},"modified":"2013-04-22T16:13:36","modified_gmt":"2013-04-22T21:13:36","slug":"how-to-display-programming-code-snippets-in-a-wordpress-post","status":"publish","type":"post","link":"https:\/\/www.jbaker.info\/demo05\/how-to-display-programming-code-snippets-in-a-wordpress-post\/","title":{"rendered":"How to Display Programming Code Snippets in a WordPress Post"},"content":{"rendered":"<p>There are a lot of examples on the Web explaining how to use &#60;pre&#62;&#60;code&#62; blocks to display programming code in a post. And there are a lot of plugins that claim they will allow you to display your code easily but I had never found one that actually worked well. <\/p>\n<p>I was frustrated with finding a simple solution to this problem. Up until today, that is. Here is a plugin that works for what I want it to do.<\/p>\n<h3>A Plugin to Post Code Snippets That Actually Works<\/h3>\n<p><a target='_blank' href=\"http:\/\/wordpress.org\/support\/view\/plugin-reviews\/code-snippet-library\">\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.jbaker.info\/wp-content\/uploads\/2013\/04\/code_snippet_plugin.jpg\" alt=\"code_snippet_plugin\" style=\"border: 1px solid black;\" width=\"550\" height=\"145\" class=\"alignleft size-full wp-image-8104\" srcset=\"https:\/\/www.jbaker.info\/demo05\/wp-content\/uploads\/code_snippet_plugin.jpg 550w, https:\/\/www.jbaker.info\/demo05\/wp-content\/uploads\/code_snippet_plugin-300x79.jpg 300w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a>\n<div class=\"xp_clear\"><\/div><\/p>\n<p>The <a href=\"http:\/\/wordpress.org\/support\/view\/plugin-reviews\/code-snippet-library\" title=\"Code Snippet Library\" target=\"_blank\">Code Snippet Library plugin<\/a> uses it&#8217;s admin section to store your snippets of code. You then display the snippet in your post by using a shortcode. When you save the snippet, the plugin generates an id number for it. You use the id with the shortcode to display the code. <\/p>\n<p>For example, I saved a PHP bubble sort and the id number was 70. To display the code you only need to put &#091;snippet id=&#34;70&#34;&#093; in your post. This is the result:<\/p>\n<p>[snippet id=&#8221;70&#8243;]<\/p>\n<p>In some ways it is a little bit of a hassle to save the code in the plugin&#8217;s admin section. But it is easy to learn to live with this because the displayed code in the post just works. And &#8216;just works&#8217; is very good.<\/p>\n<p>At this point I highly recommend this plugin if you want what seems to be foolproof way of putting code snippets in your posts. The plugin also has choices for a number of themes, both light and dark. You can find more information and download the plugin here: <a href=\"http:\/\/wordpress.org\/support\/view\/plugin-reviews\/code-snippet-library\" target='_blank' >Code Snippet Library plugin at WordPress.org<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are a lot of examples on the Web explaining how to use &#60;pre&#62;&#60;code&#62; blocks to display programming code in a post. And there are a lot of plugins that claim they will allow you to display your code easily but I had never found one that actually worked well. I was frustrated with finding&#8230;  <a href=\"https:\/\/www.jbaker.info\/demo05\/how-to-display-programming-code-snippets-in-a-wordpress-post\/\" class=\"more-link\" title=\"Read How to Display Programming Code Snippets in a WordPress Post\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-8103","post","type-post","status-publish","format-standard","hentry","category-programming-tips-and-tricks"],"_links":{"self":[{"href":"https:\/\/www.jbaker.info\/demo05\/wp-json\/wp\/v2\/posts\/8103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jbaker.info\/demo05\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jbaker.info\/demo05\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jbaker.info\/demo05\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jbaker.info\/demo05\/wp-json\/wp\/v2\/comments?post=8103"}],"version-history":[{"count":0,"href":"https:\/\/www.jbaker.info\/demo05\/wp-json\/wp\/v2\/posts\/8103\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jbaker.info\/demo05\/wp-json\/wp\/v2\/media?parent=8103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jbaker.info\/demo05\/wp-json\/wp\/v2\/categories?post=8103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jbaker.info\/demo05\/wp-json\/wp\/v2\/tags?post=8103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}