I’ve a wordpress blog directly hosted from wordpress and I use the [code] tags to post sourcecode on wordpress, that works fine so far.
Thats the original code tag I posted
[code language="xml"]
<TypeScriptTarget>ES5</TypeScriptTarget>
[/code]
But when I try to edit my posts with contained sourcecode it looks like this
and when I update my post the same not encoded symbols are shown on my blogpost too. Id don’t know what I am doing wrong here.
First, you want to make sure the
Visual Mode
in WordPress is disabled, and only useText Mode
.Then you don’t need to use a WordPress shortcode for adding a preformatted code block.
Check out the WordPress Codex Writing Code in Your Posts page:
https://codex.wordpress.org/Writing_Code_in_Your_Posts
Just use the HTML
<pre>
and<code>
HTML tags:You will notice I am using the HTML entity for the greater and less than symbols so they render correctly on the front-end of WordPress.
<
= <>
= >Resource links to the
<pre>
and<code>
elements:<pre>
tag: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/precode
tag: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/code