{"id":327,"date":"2013-03-15T10:02:26","date_gmt":"2013-03-15T10:02:26","guid":{"rendered":"http:\/\/learnlikeme.com\/?p=327"},"modified":"2013-04-01T11:51:14","modified_gmt":"2013-04-01T11:51:14","slug":"embedding-code-in-an-article","status":"publish","type":"post","link":"https:\/\/learnlikeme.com\/index.php\/embedding-code-in-an-article\/","title":{"rendered":"How to Embed Code in an Article"},"content":{"rendered":"<p>Code written directly in an Article will loose it&#8217;s formatting. The code will be written all in one line losing its code format structure. In order to maintain the code formatting, you can do the following:<\/p>\n<p><strong>In Visual editor<\/strong><\/p>\n<p>Select the block of code and press the code wrap button<\/p>\n<p><img loading=\"lazy\" title=\"LLM Help Image 41\" alt=\"LLM Help Image 41\" src=\"http:\/\/learnlikeme.com\/wp-content\/uploads\/basics\/jpg\/llm_help_img_41.jpg\" width=\"500\" height=\"170\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>In Text Editor<\/strong><\/p>\n<p>Select the block of code and press the &#8216;code snip&#8217; or &#8216;code block&#8217; button<\/p>\n<p><img loading=\"lazy\" title=\"LLM Help Image 42\" alt=\"LLM Help Image 42\" src=\"http:\/\/learnlikeme.com\/wp-content\/uploads\/basics\/jpg\/llm_help_img_42.jpg\" width=\"500\" height=\"170\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>or wrap your block of code manually in &#8216;code&#8217; or &#8216;pre&#8217; tags in the Text editor.<\/p>\n<p><img loading=\"lazy\" title=\"LLM Help Image 43\" alt=\"LLM Help Image 43\" src=\"http:\/\/learnlikeme.com\/wp-content\/uploads\/basics\/jpg\/llm_help_img_43.jpg\" width=\"234\" height=\"55\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Code Snip vs Code Block<\/strong><\/p>\n<p>Using the &#8216;code snip&#8217; button or adding the &#8216;code&#8217; tags are used for embedding code that is displayed in one line. Using the &#8216;code block&#8217; button or adding the &#8216;pre&#8217; tags are used for embedding blocks of code that are written in more than one line.<\/p>\n<p>&nbsp;<\/p>\n<p>Example of how the embedded code will appear:<\/p>\n<p><code>alert(&#039;What is your name?&#039;);<\/code><\/p>\n<p style=\"text-align: center\">\u00a0Code snip or code wrapped in &#8216;code&#8217; tags<\/p>\n<p>&nbsp;<\/p>\n<p><pre>function buttonClick(){\nalert(&#039;Button has been clicked&#039;);\n}<\/pre><\/p>\n<p style=\"text-align: center\">Code block or code wrapped in &#8216;pre&#8217; tags<\/p>\n<p>&nbsp;<\/p>\n<p><em>*Please note that executable codes or scripts such as javascript, jQuery, php, java, C+, etc. that are embeded in articles are not executed and are for display purposes only.<\/em><\/p>\n<p>&nbsp;<\/p>\n<p><a title=\"Back to Help page link\" href=\"http:\/\/learnlikeme.com\/index.php\/help\/\">::: Go back to the Help page<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Code written directly in an Article will loose it&#8217;s formatting. The code will be written all in one line losing <br \/><a href=\"https:\/\/learnlikeme.com\/index.php\/embedding-code-in-an-article\/\">more&#8230;<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[112,135,139,142,138,140,141,137,143,136],"_links":{"self":[{"href":"https:\/\/learnlikeme.com\/index.php\/wp-json\/wp\/v2\/posts\/327"}],"collection":[{"href":"https:\/\/learnlikeme.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learnlikeme.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learnlikeme.com\/index.php\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/learnlikeme.com\/index.php\/wp-json\/wp\/v2\/comments?post=327"}],"version-history":[{"count":15,"href":"https:\/\/learnlikeme.com\/index.php\/wp-json\/wp\/v2\/posts\/327\/revisions"}],"predecessor-version":[{"id":703,"href":"https:\/\/learnlikeme.com\/index.php\/wp-json\/wp\/v2\/posts\/327\/revisions\/703"}],"wp:attachment":[{"href":"https:\/\/learnlikeme.com\/index.php\/wp-json\/wp\/v2\/media?parent=327"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learnlikeme.com\/index.php\/wp-json\/wp\/v2\/categories?post=327"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learnlikeme.com\/index.php\/wp-json\/wp\/v2\/tags?post=327"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}