Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using WordPress, and when I post some post data into my WordPress post, including some html code, as follows:

<code><div id="access"></div></code>

I want the code to be displayed, but the code is not displayed.

How can I make it work?

share|improve this question

migrated from stackoverflow.com May 21 '11 at 21:27

This question came from our site for professional and enthusiast programmers.

4 Answers 4

You have to escape the < and > signs with their HTML entities:

&lt;div id="access"&gt;&lt;/div&gt;

Now, the browser doesn't render the code inside of the <code> blocks.

share|improve this answer

Try this plugin, Preserve Code Formatting, Wordpress will tend to strip some html tags.

Or you can character encode your html tags.

share|improve this answer

If it is not display correctly and shows up as regular paragraph text. You would have to format the <code> property within your style sheet if it is not yet styled.

Here is an example

code {font-family:lucida console}
share|improve this answer

Syntax Highlighter Evolved is the best plugin to use IMHO.

share|improve this answer
    
+1 on Syntax Highlighter Evolved. –  Chris_O May 22 '11 at 2:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.