How to keep html as html in wordpress?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















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.
code editor with complete html page including head and body tags



But when I change text mode to visual mode and back to text mode I can see the following:
code editor with only the content that was inside the body



I also try to wrap all the html with <pre> </pre> but no luck. Any idea?










share|improve this question




















  • 1





    Known issue. You can't really prevent that from happening. Don't use the visual editor and you'll be fine.

    – cabrerahector
    Nov 24 '18 at 4:42











  • It's not appropriate to have the other content that the visual editor throws away in a textarea.

    – Carol McKay
    Nov 24 '18 at 7:14


















0















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.
code editor with complete html page including head and body tags



But when I change text mode to visual mode and back to text mode I can see the following:
code editor with only the content that was inside the body



I also try to wrap all the html with <pre> </pre> but no luck. Any idea?










share|improve this question




















  • 1





    Known issue. You can't really prevent that from happening. Don't use the visual editor and you'll be fine.

    – cabrerahector
    Nov 24 '18 at 4:42











  • It's not appropriate to have the other content that the visual editor throws away in a textarea.

    – Carol McKay
    Nov 24 '18 at 7:14














0












0








0








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.
code editor with complete html page including head and body tags



But when I change text mode to visual mode and back to text mode I can see the following:
code editor with only the content that was inside the body



I also try to wrap all the html with <pre> </pre> but no luck. Any idea?










share|improve this question
















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.
code editor with complete html page including head and body tags



But when I change text mode to visual mode and back to text mode I can see the following:
code editor with only the content that was inside the body



I also try to wrap all the html with <pre> </pre> but no luck. Any idea?







wordpress






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 '18 at 7:03









stealththeninja

1,89911428




1,89911428










asked Nov 24 '18 at 3:53









Abdus Sattar BhuiyanAbdus Sattar Bhuiyan

1,60821540




1,60821540








  • 1





    Known issue. You can't really prevent that from happening. Don't use the visual editor and you'll be fine.

    – cabrerahector
    Nov 24 '18 at 4:42











  • It's not appropriate to have the other content that the visual editor throws away in a textarea.

    – Carol McKay
    Nov 24 '18 at 7:14














  • 1





    Known issue. You can't really prevent that from happening. Don't use the visual editor and you'll be fine.

    – cabrerahector
    Nov 24 '18 at 4:42











  • It's not appropriate to have the other content that the visual editor throws away in a textarea.

    – Carol McKay
    Nov 24 '18 at 7:14








1




1





Known issue. You can't really prevent that from happening. Don't use the visual editor and you'll be fine.

– cabrerahector
Nov 24 '18 at 4:42





Known issue. You can't really prevent that from happening. Don't use the visual editor and you'll be fine.

– cabrerahector
Nov 24 '18 at 4:42













It's not appropriate to have the other content that the visual editor throws away in a textarea.

– Carol McKay
Nov 24 '18 at 7:14





It's not appropriate to have the other content that the visual editor throws away in a textarea.

– Carol McKay
Nov 24 '18 at 7:14












1 Answer
1






active

oldest

votes


















1














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/






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53455019%2fhow-to-keep-html-as-html-in-wordpress%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    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/






    share|improve this answer




























      1














      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/






      share|improve this answer


























        1












        1








        1







        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/






        share|improve this answer













        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/







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 24 '18 at 8:15









        Riccardo MelRiccardo Mel

        317




        317
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53455019%2fhow-to-keep-html-as-html-in-wordpress%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()