displaying HTML code, as code

  • Unknown's avatar

    Hello, I am using a free version of WP. I am trying to use the code tag to show some HTML as code, but when I use the code tag the HTML gets rendered as text. For example, inside of my HTML I have an anchor tag with the text. When I wrap the anchor with the code tag, the link is displayed when I publish my blog. I want the actual code to be displayed instead. Hopefully that makes sense. Let me know if you need any more info. Thank you for the help!

    The blog I need help with is: (visible only to logged in users)

  • Unknown's avatar

    We have code restrictions. No JavaScript, no form codes, except this one https://en.support.wordpress.com/forms/contact-form, no iframes from unsupported sources or third party advertising codes, and no tracking codes, and no unsupported embeds can be used on any wordpress.COM hosted sites.

    Please read:
    https://en.support.wordpress.com/code/
    allowed HTML tags list – https://en.support.wordpress.com/code/#html-tags
    https://en.support.wordpress.com/code/#javascript
    https://en.support.wordpress.com/code/#flash-and-other-embeds

    Please see Posting Source Code
    https://en.support.wordpress.com/code/posting-source-code/

    If none of that helps you resolve the issue type modlook into the sidebar tags on this thread for a Staff follow-up. How do I get a Moderator/Staff reply for my question? https://en.support.wordpress.com/getting-help-in-the-forums/#how-do-i-get-a-moderatorstaff-reply-for-my-question Also subscribe to this thread so you are notified when they respond and be patient while waiting. To subscribe look in the sidebar of this thread, find the subscribe to topics link and click it.

  • Hi there,

    Can you please give me a link to the post/page where you’re trying to add this code? Then I can take a look for you.

  • Unknown's avatar

    thank you, timethief. The “Posting Source Code” article helped.

    kokkieh, thanks for chiming in.

    I have some feedback. I don’t know if either of you are able to pass it on to the right people.

    When I am typing a blog post, and I switch to the HTML editor, and then I click on the “code” button, I get the word “code” wrapped in angle brackets rather than square brackets.

    When I read the article mentioned above it states that it needs to be square brackets. I made that change in my blog post and it kind of appeared like it worked. When I switched back to the visual tab I had a code block, which is what I was looking for. However, the word “code” with square brackets was present.

    Just to see what what happen, I hit publish. When I viewed my published blog post I got exactly what I was looking for! So it all worked.

    My feedback: I did a lot of internet searches for this issue before I made this forum post and I couldnt find the help I needed. 1) The code starts out with angle brackets when it should be square, so that should be fixed. 2) The “language” setting should be included when I click on the code button. I never even knew that we could add that attribute. 3) Just a thought, maybe include a link on the blog post page to the support site for using the code feature.

    If you guys need screenshots please provide an email address and I’ll whip up a doc for you.

    Thanks a ton for the help!! Have a great day!

  • Unknown's avatar

    Screenshots can be helpful. You can use http://snag.gy/ or http://cloudup.com to share screenshots and link to them here. If you use the WordPress.com guide for screenshots http://en.support.wordpress.com/make-a-screenshot/ you can and upload it to your Media Library, and return to this thread to provide the file name so Staff can examine it.

  • Unknown's avatar

    ok perfect. I dont have time right now. I’ll get to it sometime in the next 48 hours and I’ll post back. Thanks!

  • Unknown's avatar
  • 1) The code starts out with angle brackets when it should be square, so that should be fixed.

    Square brackets on WordPress.com denotes a shortcode – a special code that was written especially for WordPress.com which triggers a bunch of background stuff once the post it published. In the case of the code-shortcode, it runs the syntax highlighter plugin that’s built into WordPress.com. You can use it in either the Visual or the HMTL editor, but the shortcode needs to be typed in every time – there’s no button to insert it in either editor.

    The code button in the HTML editor simply inserts the code-HTML tag. That HTML tag prevents any code you add from being executed when the page loads and displays it using the preformatted format, but it doesn’t include syntax highlighting like the shortcode does, and you cannot set a language. You can read more on the use of this HTML tag here:

    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/code

    2) The “language” setting should be included when I click on the code button.

    As mentioned above, the button in the HTML editor only inserts a HTML tag, and you cannot set a language in the HTML tag. The language option is only available in the shortcode.

    We could definitely add a shortcode button which triggers a graphic user interface to configure and insert the code like we already have for contact forms, but it would need to be built from scratch and this feature simply does not get used by enough people to justify the developer time to create something like this.

    3) Just a thought, maybe include a link on the blog post page to the support site for using the code feature.

    Again a nice idea, but there are so many other, much more commonly used features in the post editor that has an even greater claim on having support links right there. For this very reason we made the conscious decision not to have any support links inside the editor. However, if you have the posts settings sidebar open you’ll see a ? icon in the bottom right which you can use to visit our help page and search for info on a particular feature.

  • The topic ‘displaying HTML code, as code’ is closed to new replies.