• WordPress appears to translate character encoding into actual markup. I would like to display some HTML in a post. Is there someone (please) who can show me how?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Use the code tags, like this: <code>your code here</code>

    Using the <code> tags won’t always display the code either, especially if you’re attempting to show a block of PHP code.

    For a listing of HTML Special Entities I recommend starting here: WDG on HTML Special Entities. You can also google HTML Special Entities I think.

    The first line of the provided tables shows three ways to display quotation marks using this markup. I use this method for markup whenever I give code examples and it works very well.

    True, I did a little test-run myself and found that it wasn’t working very well.

    After a few minutes of research I found this handy script: https://www.simplebits.com/cgi-bin/simplecode.pl
    There are also plugins that put that functionality into wordpress if you post code often: https://codex.www.ads-software.com/Plugins/Syntax_Highlighting

    Thread Starter simonpockley

    (@simonpockley)

    I had already tried all of these (using various entities and none of them work. As soon as I save the post it translates the code into markup and then leaves behind an empty set of code elements.

    Using the WYSIWYG editor?

    I add code characters all the time and have no trouble – but I have it set to not use the WYSIWYG editor because it always mucks with the way I want things styled.

    You can see examples of my usage on Bill2me.com. I’m displaying code on the front page currently and I use the HTML Special entities.

    For example < is ‘&’ + ‘#60;’ and it displays fine.

    Thread Starter simonpockley

    (@simonpockley)

    That’s interesting. I wonder why it doesn’t work for me either in the editor or by placing the entities and code wrapping in the html editor – I’m using firefox maybe it’s the browser?

    Are you using the WYSIWYG editor or have you set it to plain text?

    It wouldn’t surprise me if the default editor (which automatically applies markup) was causing the problem. Try switching to the plain text editor and see if that helps.

    Wild is right, the key is to first disable the bulk of filtering by turning off visual-rich-editing (wysiwig) and then the extra step of a ‘code’ plugin. I use Preserve Code Formatting (the 3rd one I tried ;’) and it works well for me. For examples, click my name.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Display HTML (or other markup) in a post’ is closed to new replies.