How to display HTML, CSS, PHP, Javascript and more source codes in WordPress posts

Display code in WordPress blog posts

Displaying source code in your WordPress posts is extremely simple, you can add a <code> tag around your code and it will be displayed in your blog post.

The problem with the <code> tag in WordPress

As pointed out in Writing Code in Your Posts from the WordPress Codex, a few issues can arise from using this method if you are not careful. Using the <code> tag doesn’t tell WordPress to strip the HTML references from the post.

The Solution to displaying code in WordPress

How to display HTML, CSS, PHP, Javascript and more source codes in WordPress posts

The SyntaxHighlighter Evolved allows you to easily embed code in your WordPress blog using simple short code to give a nice looking formatted code in the frontend post display.

Simply using the following shortcode structure, your code snippets can be displayed elegantly in your post.

How to display HTML, CSS, PHP, Javascript and more source codes in WordPress posts

You can see a better example SyntaxHighlighter Evolved plugin use on our post -

How to only show the admin toolbar for administrators in a WordPress website

What is your favorite method to display code in WordPress posts?

  • Indie Extras | Kansas City web design
  • Eat It Kansas City | Kansas City web design
  • The Woods Within | Indie Horror Slasher Movie
  • Social Security On Call
  • WP Caretaker | WordPress Maintenance Services
  • Dave's Shutter and Blind | Kansas City Plantation Shutters
  • Leonard Jackson | Political and Financial Blogger
  • Blogger Local | Kansas City Web Design
  • WinPro Solutions | Kansas City Web Design
  • Pinnacle Jewelry Buyers - Kansas City
  • DG Busy Bee Cleaning | Kansas City Web Design Portfolio
  • Aine Wendler Piano Studio | Kansas City Web Design Portfolio
  • KD Reports | Video and text search engine optimized content creation for websites
  • Best Twitter Tools to get more Twitter Followers
  • Alpha Pawn Shops are Kansas City's premier pawn shops
  • The Campground, A Roman Jossart slasher
  • Peculiar Film Festival
  • DVM 1 Source
  • KC AutoGlass Website Screnshot
  • doughofthedead
  • dough_boys_pizza
  • Joe's Datacenter
  • Caitlin Ogren Photography
  • Elegant Design Events
  • Commish Advisor