[Resolved] The tag "code" does not work

Home Forums Support [Resolved] The tag "code" does not work

Home Forums Support The tag "code" does not work

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #682750
    David

    Hi team,
    When I need write some code in a post the tag “code” close before the code.

    In wordpress html/text editor, I write

    <code>
    <div>Hola mundo </div>
    </code>

    When I switch to the visual editor and go back to the html/txt editor:

    <code></code>
    <div>
    
    Hola mundo
    
    </div>
    #682823
    David
    Staff
    Customer Support

    Hi there,

    It is because <div> is a block element which ‘cannot’ sit inside an inline element such as <code>

    What are you trying to achieve with the <div> ?

    #682839
    David

    I want to publish an article with code snippets and include “div”

    #682873
    David
    Staff
    Customer Support

    Aah ok, how many articles do you intend to add ‘code’ into?
    Their are a few ways to go about it.

    #683340
    David

    Several, I’ve seen some plugin but they do not work either.
    Do you have any recommendations?

    #683452
    Lyle

    Although it hasn’t been updated in quite a long time, I still use the Pastacode plugin as I have found it to be the easiest to use and has the nicest display of all the others I have tried.

    https://wordpress.org/plugins/pastacode/

    Cheers!
    Lyle

    #683556
    David
    Staff
    Customer Support

    Thanks Lyle,

    David, within the Visual editor try just pasting in the HTML without the <code> tags. Then highlight the code block and hit the Code button. Doing it this way should escape the HTML first.

    #684135
    David

    – Lyle, I’ll try it, although it has not been updated for two years.

    – David, IT WORKS!

    Thanks to both of you πŸ˜€

    #684222
    David
    Staff
    Customer Support

    Awesome πŸ™‚ the TinyMCE can be a little fickle at times.
    If you’re gonna be doing complex codes that may need updating, and don’t mind the extra request then embed a Gist or a Codepen. You can then update the code in a decent code editor πŸ™‚

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.