Home > General, Programming > Display Code in WordPress Posts using Syntax Highlighter Evolved

Display Code in WordPress Posts using Syntax Highlighter Evolved

October 28th, 2010 Leave a comment Go to comments

There are times when you might want to show a piece of code within a WordPress post. If you try to put the code snippet directly into the editor you’ll find that WordPress doesn’t exactly display how you’d like it to.  The problem is that WordPress will assume that the code is intended to be read as code and not plain text so the readers can view it properly.

The easiest way to combat this issue is to use a plugin so that when you past code in your post WordPress knows not to see the code as code but as text.  One plugin that i have found is called SyntaxHighlighter Evolved, written by viper007bond, which is based on the original project by Alex Gorbatchev.

For a list of supported languages see the WordPress.com support document.

Using the plugin

Whenever you want to display code you will need to wrap your snippet with the shortcode tags of the corresponding language.

1
1
1

There are also several options available that you can use in your shortcode to tweak the display. The list of tweaks can be seen at the bottom of the Syntax Highlighter Options page.  If you wanted to highlight lines 4 and 12 of your php code you could do the following:

1

Sample output:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>PHP Code Example</title>
</head>
<body>
	<h1>PHP Code Example</h1>

	<p><?php echo 'Hello World!'; ?></p>

	<p>This line is highlighted.</p>

	<div>
		This	is	an
		example	of	smart
		tabs.
	</div>

	<p><a href="http://wordpress.org/">WordPress</a></p>
</body>
</html>
Categories: General, Programming Tags: , , ,
  1. November 12th, 2010 at 21:24 | #1

    i want it

  2. November 14th, 2010 at 16:14 | #2

    how to use

  3. November 16th, 2010 at 01:29 | #3

    cool

  4. November 20th, 2010 at 14:28 | #4

    Good day!This was a really marvelous website!
    I come from milan, I was luck to search your website in bing
    Also I learn much in your topic really thanks very much i will come every day

  5. November 22nd, 2010 at 00:17 | #5

    this i use

  6. November 22nd, 2010 at 09:53 | #6

    Good day I was fortunate to search your blog in google
    your post is marvelous
    I obtain a lot in your Topics really thank your very much
    btw the theme of you blog is really terrific
    where can find it

  7. November 24th, 2010 at 03:09 | #7

    ah

  8. November 26th, 2010 at 16:54 | #8

    That was a really insightful view. Thanks for sharing your advice for those people requiring aid :)

  9. November 27th, 2010 at 23:07 | #9

    jeffpollreisz.com I hadn’t noticed before. I will back again!

  10. November 28th, 2010 at 02:30 | #10

    Sweet site style. jeffpollreisz.com will back again!

  11. November 30th, 2010 at 04:22 | #11

    How so?

  12. November 30th, 2010 at 09:43 | #12

    In my opinion you are not right. Write to me in PM, we will communicate.

  13. November 30th, 2010 at 11:58 | #13

    I consider, that you commit an error. Let’s discuss it.

  14. December 3rd, 2010 at 02:11 | #14

    ЎUf, me gustу! Tan clara y positiva.

    Nicolas

  15. December 4th, 2010 at 22:31 | #15

    I can recommend to come on a site where there is a lot of information on a theme interesting you.

  16. December 5th, 2010 at 01:26 | #16

    It is remarkable, rather amusing answer

  17. December 5th, 2010 at 04:30 | #17

    I apologise, but, in my opinion, you commit an error. I can defend the position.

  18. December 6th, 2010 at 09:54 | #18

    It’s eerie, that usually the most simple advice are often the most helpful! I will adopt these tips into preparation and see the outcome. Thanks for this page!

  19. December 6th, 2010 at 14:04 | #19

    hi thanks for the article.

  20. December 6th, 2010 at 21:41 | #20

    @tattoo supply  
    @bell ross watches
    It is definitely possible that i have an error, could you please point out the error(s) you’re referring to so i can correct them? Thanks

    @Everyone – You’re very welcome and glad you found this useful and informative.

  21. December 7th, 2010 at 08:12 | #21

    Definitely, what a great website and illuminating posts, I will bookmark your website.All the Best!

  22. December 7th, 2010 at 10:16 | #22

    I found this info is very useful. Thanks for sharing. Do you mind whether I quote a few paragraphs from this article in our website if it’s acknowledged you to be the writer and links back to this page? Thank you!

  23. December 7th, 2010 at 22:47 | #23

    @Tamera Lightle
    No i don’t mind at all. I just ask that you link back to the article. Thanks.

  24. December 8th, 2010 at 13:45 | #24

    I uncovered your blog using google and I must say, this is without doubt one of the best well drafted articles I have viewed in a long time. I have bookmarked your site for added posts.

  25. December 11th, 2010 at 13:35 | #25

    Wow, you truly have organized some especially helpful resources on this website. I’ve recently been evaluating a lot of them and this collection is definitely impressive. It is incredible the number of superb free software programs and scripts have been created by some really talented individuals.

  26. December 12th, 2010 at 00:52 | #26

    Unlike to some statements, proper researched articles still drag in readers such as me. This is my first time I visit here. I found lots of interesting stuff in the blog mostly its discussion.

  27. December 13th, 2010 at 16:44 | #27

    yours web sites is very nice.Where do you find articles is kind of this?

  28. December 14th, 2010 at 04:44 | #28

    Me and my friend were arguing about an issue related to this! Now I know that I was right. lol! Appreciate it for the information you blog post. With regards, Christene.

  29. December 16th, 2010 at 07:41 | #29

    I’m still learning from you, while I’m trying to achieve my goals. I definitely liked reading everything that is posted on your website.Keep the aarticles coming. I enjoyed it!

  30. December 16th, 2010 at 23:03 | #30

    Sorry my english, but this is great site, I wil add to my favorites.

  31. December 17th, 2010 at 12:28 | #31

    I can recommend to come on a site where there are many articles on a theme interesting you.

  32. December 17th, 2010 at 13:03 | #32

    Funny my partner and I were only just speaking about this same idea with my buddy. Your thoughts are exactly like we both had. I have sent him a link to this post

  33. December 17th, 2010 at 14:37 | #33

    great post, thanks for sharing

  34. December 17th, 2010 at 23:01 | #34

    I don’t usually agree with the comments that are shown on websites but in this case I agree.

  35. December 18th, 2010 at 06:25 | #35

    Wow! Thank you! I always needed to write on my blog something like that. Can I include a fragment of your post to my website?

  36. December 18th, 2010 at 20:33 | #36

    Good entry. I appreciate you for posting it. Keep up the fine blogging.

  37. December 19th, 2010 at 08:11 | #37

    What i find difficult is to find a blog that can capture me for a minute but you definitely add value. Keep it like this.

  38. December 19th, 2010 at 08:36 | #38

    I’m still learning from you, but I’m trying to achieve my goals. I absolutely liked reading everything that is posted on your website.Keep the stories coming. I loved it!

  39. December 19th, 2010 at 08:53 | #39

    You made some good points there. I did a search on the subject and found most guys will agree with your website.

  40. December 20th, 2010 at 01:58 | #40

    hey all, I was just checkin’ out this blog and I really love the basis of the article, and have nothing to do, so if anyone would like to to have an enjoyable convo about it, please contact me on myspace, my name is clarissa johnson

  41. December 20th, 2010 at 09:47 | #41

    I enjoy men and women who actually who post often, it is really hard to receive all form of understanding any other way. Quality job.

  42. December 20th, 2010 at 13:35 | #42

    I’ve learned so much over the internet in the past years. The most of my know-how I credit to studying good weblogs like yours. Thanks a lot!

  43. December 24th, 2010 at 00:32 | #43

    ….Added Nov 15 2008 Under ….I recently ran a whole lot of WordPress code highlighting plug-ins through the grinder and ended up selecting four that in my opinion are the worthiest of the lot..Writing a code highlighter plug-in proves to be a fairly difficult exercise. For instance if the plug-in is activated using the pre tag then it needs to maintain a stack counter of pre and pre tags so that finding a pre tag in the code being highlighted doesnt abruptly terminate the code parsing disfiguring your blog in the process. .Tag sourcecode language css code here sourcecode .My main issue with this plug-in is that it works in visual mode hence your source code formatting tabs etc. is lost.

  44. December 24th, 2010 at 01:55 | #44

    Well … all I can say is, wow. This is an impressive collection of resources, thank you for taking the time to put everything together.

  45. December 25th, 2010 at 10:02 | #45

    Superb blog post, a bunch of great data. I am about to show my girlftriend and ask them what they think.

  46. December 26th, 2010 at 00:16 | #46

    Salutation, i study your blog often and i own an correspondent one and i used to be just wondering if you get much of spam comments? If thus how do you stop it, any plugin or anything you’ll be able to give notice? I get thus often lately it’s driving me crazy so any help is very abundant appreciated. for older folks, retirement or a huge promotion at work is a time when celebration events are going to be a great idea.

  47. December 26th, 2010 at 03:59 | #47

    Realy good work cheers mate! Thx and btw – Merry Xmas!

  48. December 26th, 2010 at 07:11 | #48

    Great blog it’s not often that I comment but I felt you deserve it.

  49. December 26th, 2010 at 10:37 | #49

    Keep up blogging! its getting through the tough times that cause you stronger and then the good times will follow, keep working about your experiences and we should all pull together.

  50. December 26th, 2010 at 13:49 | #50

    Gingle bells, gingle bells, gingles all the way…Merry Christmas and a Happy new year

  51. December 26th, 2010 at 20:21 | #51

    I really like professionals who blog, it’s very difficult to acquire that variety of understanding any other means. Remarkable job.

  52. December 26th, 2010 at 20:34 | #52

    Aw, this was a really quality post. In theory I’d like to write like this also – taking time and real effort to make a good article… but what can I say… I procrastinate alot and never seem to get anything done… Regards…

  53. December 28th, 2010 at 00:50 | #53

    Pretty right subdivision. I just came across your web site and wanted to say that I have really enjoyed reading your opinions. In any caseI’ll be coming back and I hope you post over again soon.

  54. December 28th, 2010 at 08:27 | #54

    I find myself coming to your blog more and more often to the point where my visits are almost daily now!

  55. December 28th, 2010 at 09:33 | #55

    I enjoy reading a lot and your stories are worth reading, nice blog, keep it up.

  56. December 28th, 2010 at 16:33 | #56

    Hi. I wanted to drop you a quick note to express my thanks. I’ve been following your blog for a month or so and have picked up a ton of good information as well as enjoyed the way you’ve structured your site.

  57. December 29th, 2010 at 04:46 | #57

    Keep working ,great job!

  58. December 29th, 2010 at 04:54 | #58

    Great articles and nice a website design too :)

  59. December 29th, 2010 at 05:04 | #59

    I’ve been visiting your blog for a while now and I always find a gem in your new posts. Thanks for sharing.

  60. December 29th, 2010 at 05:32 | #60

    I’ve been visiting your blog for a while now and I always find a gem in your new posts. Thanks for sharing.

  61. December 29th, 2010 at 05:42 | #61

    Your blog provides a fresh look at the subject. Great job mate!

  62. December 29th, 2010 at 06:13 | #62

    I suppose it depends on how you look at it. There’s usually another way.

  63. December 29th, 2010 at 06:30 | #63

    You have some bugs in html or css code in the footer.

  64. December 29th, 2010 at 06:39 | #64

    Keep working ,great job!

  65. December 29th, 2010 at 06:47 | #65

    Keep posting stuff like this i really like it! Good job friend!

  66. December 29th, 2010 at 06:59 | #66

    I really enjoyed reading this. I think I will that a look through your other posts!

  67. December 29th, 2010 at 07:28 | #67

    I know this is really boring and you are skipping to the next comment, but I just wanted to throw you a big thanks, you cleared up some things for me!

  68. December 29th, 2010 at 17:12 | #68

    Hey I just wanted to let you know, I actually like the written material on your site. But I am using Chromium on a machine running version 8.x of Xubuntu and the design aren’t quite right. Not a big deal, I can still fundamentally read the articles and search for information, but just wanted to inform you about that. The navigation bar is kind of hard to use with the config I’m running. Keep up the great work!

  69. December 30th, 2010 at 00:44 | #69

    very informative post. Looking more to something like this

  70. December 30th, 2010 at 02:00 | #70

    Greeting, perhaps this is not on topic but anyhow, I have been browsing about your web site and it looks truly tidy. impassioned about your writing. I’m building a new blog and hard put to make it appear great, and provide really good content. I have revealed much on your site and I look forward to more updates and will be coming back.

  71. December 30th, 2010 at 08:34 | #71

    I always visit your blog and retrieve everything you post here but I never commented but today when I saw this post, I couldn’t stop myself from commenting here. Fantastic article mate!

  72. December 30th, 2010 at 08:51 | #72

    The most comprehensive and very well thought out write up I have found on this subject on the net. Keep on writing, I will keep on coming by to read your new content. This is my fourth time coming by your blog.

  73. December 30th, 2010 at 16:47 | #73

    Great articles and nice a website design too :)

  74. December 30th, 2010 at 21:29 | #74

    Please add more stories. I would like to publish this in our company publication and yes, credit goes to you.

  75. December 31st, 2010 at 01:42 | #75

    Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! I’m sure you had fun writing this article.

  76. December 31st, 2010 at 06:17 | #76

    Very interesting website. I am so looking forward to reading more posts.

  77. December 31st, 2010 at 22:38 | #77

    This website is great. I am gonna put this in my bookmarks before I lose the link, I don’t think I’ll ever find my way back here again otherwise!

  78. January 1st, 2011 at 17:55 | #78

    Pretty insightful post. Never thought that it was this simple after all. I had spent a good deal of my time looking for someone to explain this subject clearly and you’re the only one that ever did that. Kudos to you! Keep it up

  79. January 2nd, 2011 at 11:42 | #79

    Hi! I found your blog on Yahoo.It’s really comprehensive and it helped me a lot.

    Continue the good work!

  80. January 3rd, 2011 at 02:52 | #80

    At Long Last, an issue that I am passionate about. I have looked for information of this topic for the last several hours. Your site is greatly treasured.

  81. January 3rd, 2011 at 03:24 | #81

    Thanks For This post, was added to my bookmarks.

  82. January 4th, 2011 at 12:41 | #82

    hi!,I like your writing very much! share we communicate more about your article on AOL? I require a specialist on this area to solve my problem. Maybe that’s you! Looking forward to see you.

  83. January 5th, 2011 at 21:51 | #83

    I’d prefer to thank you for the efforts you’ve created on paper this submit.

  84. January 6th, 2011 at 03:38 | #84

    Having been simply looking at useful blog content with regard to our project research when I happened to stumble on yours. Thanks for the useful info!

  85. January 7th, 2011 at 05:09 | #85

    I truly prize your work , Great post.

  86. January 7th, 2011 at 08:52 | #86

    Just blowing some free time on Stumbleupon and I found your entry. Not typically what I like to learn about, but it was definitely worth my time. Thanks.

  87. January 8th, 2011 at 03:07 | #87

    I found this blog post to be very good. I have already gone through and read many of your posts. They are good!

  88. January 9th, 2011 at 15:30 | #88

    All roads lead to Rome.All that ends well is well.

  89. January 9th, 2011 at 18:10 | #89

    cool

  90. January 9th, 2011 at 21:58 | #90

    I wanted to say your blog is very good. I always like to hear a thing new about this since I have the similar blog in my Region on this subject so this help´s me a lot. I did a search on the matter and discovered a very good number of blogs but absolutely nothing like this.Thanks for sharing so much within your blog.

  91. January 10th, 2011 at 03:00 | #91

    I am not new to blogging and really treasure your web site. There is much original subject that peaks my interest. I am going to bookmark your internet site and keep checking you out.

  92. January 10th, 2011 at 10:31 | #92

    Nice content you got here for your site, any suggestions?

  93. January 11th, 2011 at 11:38 | #93

    I think like this too…

  94. January 12th, 2011 at 08:46 | #94

    Hello, what a fantastic knowledge in your internet site here

  95. January 12th, 2011 at 13:10 | #95

    Damn, I’ve been looking for information like this for a while now. Thanks!

  96. January 12th, 2011 at 23:36 | #96

    This is my second visit to this blog. I am thinking about starting a brand new blog in the same category. Your site gave me some information to work with. (Don’t worry, I won’t be copying you :) ) You have done a fantastic job.

  97. January 13th, 2011 at 05:55 | #97

    I am always browsing online for tips that can assist me. Thx!

  98. January 13th, 2011 at 09:21 | #98

    I’m obtaining an essential minimal trouble I cant appear to be capable of subscribe your personal feed, I’m working with the search engines reader.

  99. January 13th, 2011 at 14:19 | #99

    Nice article, thanks. I signed to your blog RSS.

  100. January 13th, 2011 at 23:20 | #100

    Interesting and useful information. I just wanna tell U “Thanks”. Thanks!

  101. January 14th, 2011 at 08:44 | #101

    whoah this blog is great i love reading your articles. Keep up the great work! You know, lots of people are hunting around for this information, you can aid them greatly.

  102. January 14th, 2011 at 13:27 | #102

    Good site, you’ve gotta tell us your secrets ;) haha

  103. January 15th, 2011 at 10:59 | #103

    I’ve really discovered a great deal studying this page. Plainly especially excellent content here.

  104. January 15th, 2011 at 22:52 | #104

    You made a few nice points there. I did a search on the subject and found mainly persons will have the same opinion with your blog.

  105. January 17th, 2011 at 09:12 | #105

    Thanks a lot, wonderful job! It was the thing I needed to get. When I click your Feed it appears to be a ton of garbled text, may be the malfunction on my side?

  106. January 18th, 2011 at 00:52 | #106

    Only a smiling visitor here to share the love (:, btw outstanding layout.

  107. January 18th, 2011 at 02:19 | #107

    Good write-up, I’m normal visitor of one’s site, maintain up the excellent operate, and It’s going to be a regular visitor for a long time.

  108. January 18th, 2011 at 05:25 | #108

    great web site yo have here btw

  109. January 18th, 2011 at 08:00 | #109

    Pretty insightful post. Never thought that it was this simple after all. I had spent a good deal of my time looking for someone to explain this subject clearly and you’re the only one that ever did that. Kudos to you! Keep it up

  110. January 18th, 2011 at 08:34 | #110

    An interesting discussion is worth comment. I think that you should write more on this topic, it might not be a taboo subject but generally people are not enough to speak on such topics. To the next. Cheers

  111. January 18th, 2011 at 20:49 | #111

    After examine just a few of the weblog posts on your web site now, and I truly like your method of blogging. I bookmarked it to my bookmark website listing and will be checking back soon. Pls check out my site as properly and let me know what you think.

  112. January 19th, 2011 at 07:12 | #112

    I was just going through your site it is extremely well crafted, What i’m searching on the internet trying to find out the correct way to start this blog thing and your website happens to be really high quality.

  113. January 19th, 2011 at 09:30 | #113

    Awesome post Jeff! You guys are doing awesome work!

  114. January 19th, 2011 at 14:41 | #114

    I like what you guys are up also. Such clever work and reporting! Keep up the superb works guys I’ve incorporated you guys to my blogroll. I think it’ll improve the value of my site :) )

  115. January 20th, 2011 at 09:33 | #115

    Just saying thanks will not just be sufficient, for the tremendous lucidity in your writing. I will right away grab your rss feed to stay abreast of any updates.

  116. January 20th, 2011 at 10:47 | #116

    Really cool site. Thank you for writing.

  117. January 20th, 2011 at 18:15 | #117

    After reading this I thought it was very informative.

  118. January 20th, 2011 at 21:34 | #118

    Hello from Russia! Ought to it be easy for me to pages and use a submit in your weblog while using link to you? I’ve tried emailing you relating to this problem nonetheless it seems i cant achieve you, please response after have a moment, thanks.

  119. January 21st, 2011 at 10:08 | #119

    Hi i am so pleased I found your blog, I really found you by mistake, while I was searching Yahoo for something else, At Any Rate I am here now and would just like to say thank you for a wonderful blog posting and a all round intriguing blog (I also love the theme/design), I do not have time to read it all at the right now but I have bookmarked it and also added your RSS feeds.

  120. January 21st, 2011 at 11:33 | #120

    Straight to the point and written well, I appreciate for the post. I merely wish there have been more goodies on the internet today, thanks and will God Bless…

  121. January 21st, 2011 at 16:27 | #121

    Good entry. I appreciate you for posting it. Keep up the fine blogging.

  122. January 22nd, 2011 at 02:13 | #122

    Hi. I wanted to drop you a quick note to express my thanks. I’ve been following your blog for a month or so and have picked up a ton of good information as well as enjoyed the way you’ve structured your site.

  123. January 22nd, 2011 at 12:47 | #123

    Well, this is my initial go to to your weblog! We are a group of volunteers and starting a new initiative in a very community in the identical niche. Your website offered us valuable data to work on. You have done a marvellous work!

  124. January 23rd, 2011 at 09:50 | #124

    Hi! I found your blog on Yahoo.It’s really well written and it helped me a lot.

    Continue the good work!

  125. January 23rd, 2011 at 11:13 | #125

    Thank you. This works like a dream!

  126. January 23rd, 2011 at 15:45 | #126

    Very nice, gives me a lot of inspiration being right in the midst of a redesign. It’s all in the details and comment forms are definitely overlooked more often than not. Time well spent on this post.

  127. January 23rd, 2011 at 22:49 | #127

    Great post Jeff. Can’t be more excited to see where you guys end up another 12 months from now.

  128. January 24th, 2011 at 00:06 | #128

    Wow, marvelous blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your web site is magnificent, as well as the content!

  129. January 24th, 2011 at 02:40 | #129

    I love jeffpollreisz.com! Here I always find a lot of helpful information for myself. Thanks you for your work.
    Webmaster of http://loveepicentre.com and http://movieszone.eu
    Best regards

  130. January 24th, 2011 at 11:51 | #130

    Hey, I attempted to email you about this article that i’ve a few inquires, but can’t seem to reach you. Please email me when have a minute. Thanks.

  131. January 24th, 2011 at 18:24 | #131

    Great job on the blog, it looks great. I am going to bookmark it and will make sure to check back weekly

  132. January 25th, 2011 at 16:55 | #132

    Really good site. Thank you for posting.

  133. January 25th, 2011 at 21:18 | #133

    Someone I work with visits your blog frequently and recommended it to me to read too. The writing style is great and the content is top-notch. Thanks for the insight you provide the readers!

  134. January 26th, 2011 at 09:40 | #134

    Once again informative article ! Thanks a lot :-)

  135. January 26th, 2011 at 13:59 | #135

    Wow, what a Excellent outline :-) Good shout !

  136. February 3rd, 2011 at 16:33 | #136

    I really enjoyed reading this post. Great step by step description!

  137. February 5th, 2011 at 04:18 | #137

    I really enjoyed reading this post. Great step by step description!

  138. February 7th, 2011 at 04:47 | #138

    kinda like the article you posted . it just isn’t that easy to find good stuff toactually read (you know.. READ! and not simply browsing through it like a zombie before going to yet another post to just ignore), so cheers man for really not wasting my time on the god forsaken internet. :)

  139. February 7th, 2011 at 10:01 | #139

    keep up the good work on the site. I like it. Could use some more frequent updates, but i’m sure you got better stuff to do like we all do. =)

  1. No trackbacks yet.
*