{"id":857,"date":"2013-10-28T17:33:06","date_gmt":"2013-10-28T17:33:06","guid":{"rendered":"http:\/\/scunster.co.uk\/?p=857"},"modified":"2013-11-21T09:50:12","modified_gmt":"2013-11-21T09:50:12","slug":"getting-wordpress-to-display-htlm-code-in-an-article","status":"publish","type":"post","link":"https:\/\/scunster.co.uk\/?p=857","title":{"rendered":"Getting wordpress to display html code in an article"},"content":{"rendered":"<p>By default WordPress will not display html tags or code in a published article. try it for yourself, copy a few lines of code and paste them into a published article!<\/p>\n<p>Sometimes if you want to share code this is going to be a problem.<\/p>\n<p>To get around this all you need to do is go to <a href=\"http:\/\/www.opinionatedgeek.com\/DotNet\/Tools\/HTMLEncode\/Encode.aspx\" target=\"_blank\">http:\/\/www.opinionatedgeek.com\/DotNet\/Tools\/HTMLEncode\/Encode.aspx<\/a> and encode your html code. This is as easy as copy and paste!<\/p>\n<p>Now go to the article you want to have the code appear in and change from visual to text mode on the editor.<\/p>\n<p>Paste the encoded text where you&#8217;d like it to appear<\/p>\n<p>At the beginning of the code you have just pasted add &lt;code&gt; and at the end of the text add &lt;code&gt;<\/p>\n<p>Your html code will now appear as it should do!<\/p>\n<p><code>&lt;!DOCTYPE html&gt;<br \/>\n&lt;html&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;title&gt;Title of the document&lt;\/title&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;<br \/>\nThe content of the document......<br \/>\n&lt;\/body&gt;<\/code><\/p>\n<p>You&#8217;ll notice that the code in this article stands out as it has it&#8217;s own text color and background color. This is achieved by editing your templates css file and adding \/ changing the relevant attributes of the #code section. Anything then written in between the code tags will look how you want it to.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default WordPress will not display html tags or code in a published article. try it for yourself, copy a few lines of code and paste them into a published article! Sometimes if you want to share code this is going to be a problem. To get around this all you need to do is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[165,174],"tags":[],"class_list":["post-857","post","type-post","status-publish","format-standard","hentry","category-websdesign","category-wordpress"],"_links":{"self":[{"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/857","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=857"}],"version-history":[{"count":8,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/857\/revisions"}],"predecessor-version":[{"id":897,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/857\/revisions\/897"}],"wp:attachment":[{"href":"https:\/\/scunster.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=857"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=857"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=857"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}