Hi Seth,
I was able to replicate and, after a bit of research, found that this is a widely spread issue with displaying HTML as plain text.
You can workaround it by replacing the < and > characters with the < and > character entities.
Alternatively, you can consider a plugin that enables you to copy/paste HTML directly or pasting HTML to a third-party tool like pastebin.com. Some suggestions for plugins and paste tools are listed out here:
https://codex.ww.wp.xz.cn/Writing_Code_in_Your_Posts#Resources
Let me know how if that helps you out or if you have any extra questions.
Thread Starter
Anonymous User 5466832
(@anonymized-5466832)
Thank you Siobhan for your support! Would it be possible to suggest this to the Automattic team as a fix for the P2 theme? In my testing, the code tag is working in the default WordPress themes and premium themes I’m using from StudioPress.
I can use an outside service such as gist – but embedding the content via gist doesn’t allow the text to be searchable via the search box in P2. I’m looking to have P2 be a project management and workflow utility, and being able to search code snippets would be pretty massive. Can you please forward that feedback on to the team? I know P2 isn’t a priority, but there is so much potential!
~Seth
Hi Seth,
What specific default themes were you able to get this working with? I tested the <pre> and <code> tags with Twenty Sixteen and Twenty Fifteen, but the HTML did not display on either theme.
From the list of plugins and paste tools that I linked to, I gave the SyntaxHighlighter Evolved plugin a try (this is an Automattic-made plugin). The plugin enabled me to display HTML by wrapping it in [HTML] [/HTML] tags:
[HTML]<h2>Test</h2>[/HTML]
Could you give that plugin a try too? I think it may work well for you.
I’m also very happy to see that you’re using P2! I agree that there’s a lot of potential.
If you haven’t already, then you may wish to consider experimenting with O2, also:
https://wptavern.com/o2-is-now-available-on-github
If you download P2 Breathe and then activate O2, a “code” button will automatically appear in the front-end editor’s toolbar that you can use to display HTML. This is the version of P2 that we use internally at Automattic.
Let me know if you have any questions around the above.
Thread Starter
Anonymous User 5466832
(@anonymized-5466832)
You’re right, it was actually parsing the code in my theme. I’ll give the Automattic solution a try, hopefully it will allow the code snippets to be searchable. Thank you for the support!!