WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] <code>-tag not functioning properly?

[Resolved] <code>-tag not functioning properly?

  • chartinael

    @chartinael

    Hi guys,

    I have a draft post where I store all the wp body edits I had to make in order for wordpress to do what I need it to do.

    I enter location and code to be changed.

    The code I put between the code-tag but somehow it does get parsed.

    so i.e. I end up with

    Line xyz
    <code>
    $pee = preg_replace('/<p>\s*?(' . get_shortcode_regex() . ')\s*< \/p>/s', '$1', $pee); // don't auto-p wrap shortcodes that stand alone
    </p></code>

    where the </p> was added by wordpress’ tag closing feature. And thus it displays on preview an nicely added paragraph so I know that the code inside the code-tags does get parsed.

    or at another place it closes a <code>-tag even though there are no open code-tags at all.

    Anyhow, is this a bug? is there anywhere I can look and adjust code to make it work?

Viewing 3 replies - 1 through 3 (of 3 total)
  • esmi

    @esmi

    Forum Moderator

    The <code></code> tags are just markup. They don’t escape your code or stop it being parsed. You need to encode all opening < and closing > tags to stop it being parsed.

    Additionally the <code></code> are inline markup elements which means that they should be enclosed in a block-level element such as <p></p>, <div></div> or <pre></pre>. So WP is acting correctly in this instance. Personally, I enclose blocks of pre-encoded scripting for display inside <pre><code></code></pre> tags and WP doesn’t interfere at all.

    chartinael

    @chartinael

    so how does this code tag here in the forum function? Cause it does what I thought the code button in the wp editor ought to be doing?

    chartinael

    @chartinael

    Code Markup: a WordPress plugin

    This plugin does the job and assigns the <code>-tag with the appropriate functionality.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] <code>-tag not functioning properly?’ is closed to new replies.
Skip to toolbar