Reputation: 3074
I am using codeMirror to add TryIt Editor as like w3school. The following is working fine:
<form>
<textarea id="code" name="code">
HTML CODE
</textarea>
</form>
But it is not working when I try to replace HTML CODE by the actual content as follows:
<form>
<textarea id="code" name="code">
<?php the_content(); ?>
</textarea>
</form>
I find out the actual reason behind this problem. When I save post in text mode(as following image) all html looks okay.
But when I change text mode to visual mode and back to text mode I can see the following:
I also try to wrap all the html with <pre> </pre>
but no luck. Any idea?
Upvotes: 0
Views: 161
Reputation: 161
Note issue of tinyMCE on WP.
You can check using this plugin: https://wordpress.org/plugins/preserved-html-editor-markup/
But if you want a preatty clean solution you can use SHORTCODE to render your HTML structure inside the post safely.
SHORTCODE DOCS: https://codex.wordpress.org/Shortcode_API
or see this guide (in italian lang but you can translate it).
https://www.targetweb.it/come-creare-shortcode-wordpress-la-guida-completa/
Upvotes: 1