Title: Shortcodes and source code
Last modified: August 19, 2016

---

# Shortcodes and source code

 *  [plnelson](https://wordpress.org/support/users/plnelson/)
 * (@plnelson)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/shortcodes-and-source-code/)
 * I want to blog about programming, with source code examples. I’ve tried &ltpre&
   gt (“preserve code formatting”) and it works but it’s not pretty. Then I saw 
   this: [http://en.support.wordpress.com/code/posting-source-code/](http://en.support.wordpress.com/code/posting-source-code/),
   where it implies that WordPress already has available shortcodes for displaying
   source code.
 * But when I tried using some of the suggested shortcodes, e.g., `[sourcecode language
   ="xml"]` or `[sourcecode language="xml"]` they didn’t seem to do anything at 
   all and the `[sourcecode language="xml"]` appears literally in the post. Is there
   something I have to do to enable the sourcecode shortcode?
 * Thanks in advance.

Viewing 14 replies - 1 through 14 (of 14 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/shortcodes-and-source-code/#post-1844183)
 * Take a look at some of the posts in [my site](http://wordpress.mcdspot.com/).
   I use the plugin [SyntaxHighlighter Evolved](http://wordpress.org/extend/plugins/syntaxhighlighter/).
 *  Anonymous User
 * (@anonymized-3085)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/shortcodes-and-source-code/#post-1844232)
 * For self hosted installs, check the credits section on that page on WordPress.
   com
 *  Thread Starter [plnelson](https://wordpress.org/support/users/plnelson/)
 * (@plnelson)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/shortcodes-and-source-code/#post-1844271)
 * **_Take a look at some of the posts in my site. I use the plugin SyntaxHighlighter
   Evolved. _**
 * I tried it; it worked great for Java but mangled my XML. Here’s a screenshot:
   [http://blog.nelsondev.net/images/SH_Evolved_1.jpg](http://blog.nelsondev.net/images/SH_Evolved_1.jpg)
 * So I posted a question to their forum, [http://www.viper007bond.com/wordpress-plugins/syntaxhighlighter/](http://www.viper007bond.com/wordpress-plugins/syntaxhighlighter/)
   I included some sample XML which I placed between `[code]...[/code]`‘s as it 
   suggested. And it mangled the display of that XML, too! Not only that, it failed
   in a different way than in the screenshot, and it failed differently in Firefox
   and IE.
 * Anyway, my original question was about the shortcodes mentioned in [http://en.support.wordpress.com/code/posting-source-code/](http://en.support.wordpress.com/code/posting-source-code/).
   How do I get that to work?
 * BTW, I’m using WP 3.0.1
 *  Thread Starter [plnelson](https://wordpress.org/support/users/plnelson/)
 * (@plnelson)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/shortcodes-and-source-code/#post-1844272)
 * **For self hosted installs, check the credits section on that page on WordPress.
   com**
 * Thanks, but my question is really about the shortcodes mentioned in [http://en.support.wordpress.com/code/posting-source-code/.](http://en.support.wordpress.com/code/posting-source-code/)
 *  Anonymous User
 * (@anonymized-3085)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/shortcodes-and-source-code/#post-1844279)
 * > Credits
   >  [ Alex Gorbatchev’s SyntaxHighlighter project was used in the implemention of this feature. If you are a [WordPress.org](http://en.support.wordpress.com/com-vs-org/) user
   > and would like to use this feature on your self-hosted blog, it is available
   > as a [plugin](http://wordpress.org/extend/plugins/syntaxhighlighter/).
 * ie. it specifically mentions which plugin those shortcodes are based upon, so
   that should have been your starting point.
 *  Thread Starter [plnelson](https://wordpress.org/support/users/plnelson/)
 * (@plnelson)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/shortcodes-and-source-code/#post-1844282)
 * > ie. it specifically mentions which plugin those shortcodes are based upon, 
   > so that should have been your starting point.
 * I don’t want to implement my **own** shortcode, i.e., I don’t want to reinvent
   what they’ve already done; I just want to **use** the shortcodes described in
   the link. Also, **everything** is based on Alex’s code – I’ve already installed
   SyntaxHighligher-Evolved and SyntaxHighlighterPlus which are also based on it,
   and they include it in their own installs.
 * Anyway, I though the comment you quoted was just giving credit to Alex – are 
   you saying that if I install Alex’s plugin the the shortcodes will just automagically
   work?
 *  Thread Starter [plnelson](https://wordpress.org/support/users/plnelson/)
 * (@plnelson)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/shortcodes-and-source-code/#post-1844284)
 * . . . also, the link in the credit doesn’t go to Alex Gorbatchev’s Syntax Highlighter;
   it goes to SyntaxHighlighterEvolved by someone named “Viper007Bond”. And I already**
   have** that installed! That was the one I posted the screenshot of, above.
 * So getting back to my original question: what are the steps needed to get the`
   sourcecode` shortcode to work?
 *  Thread Starter [plnelson](https://wordpress.org/support/users/plnelson/)
 * (@plnelson)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/shortcodes-and-source-code/#post-1844287)
 * If I use the shortcode syntax `[sourcecode language="xml"]` with SyntaxHighlighterEvolved
   activated, I get exactly the same output I had in the screenshot above:
 * [http://blog.nelsondev.net/images/SH_Evolved_1.jpg](http://blog.nelsondev.net/images/SH_Evolved_1.jpg)
 * I’m still confused by why the link in the credits points to SytaxHighlighterEvolved
   instead of SyntaxHighlighter. But I noticed that Viper007Bond’s first name is
   Alex, so is it the same author?
 * Anyway, does anyone actually know what’s going on with the sourcecode shortcode
   or are we all just speculating?
 *  [Khang Minh](https://wordpress.org/support/users/oddoneout/)
 * (@oddoneout)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/shortcodes-and-source-code/#post-1844293)
 * [This](http://blog.nelsondev.net/images/SH_Evolved_1.jpg) is the result you got
   from editing post in the Visual Editor. The Visual Editor of WordPress will convert
   all those special characters to HTML entities. In my opinion, you have two choices:
   1. using only the HTML editor (it’s a pain, I know), or 2. when you add a block
   of code, add it like this (without spaces):
    [code]< pre>--Your code here--</
   pre >[/code].
 * Hope that might help 🙂
 *  Thread Starter [plnelson](https://wordpress.org/support/users/plnelson/)
 * (@plnelson)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/shortcodes-and-source-code/#post-1844294)
 * **This is the result you got from editing post in the Visual Editor. The Visual
   Editor of WordPress will convert all those special characters to HTML entities.**
 * **Nope.** I did **not **edit the post in the Visual editor.
 * I only edit my posts in the HTML editor. I have to because I’m using the Preserve
   Code Formatting plugin, as I mentioned in the OP, and as you note, the Visual
   Editor plays havoc with stuff like that.
 * I really appreciate everyone’s attempts to guess here, but, please let’s **stop
   speculating**! My original post was about the sourcecode shortcode described 
   in [http://en.support.wordpress.com/code/posting-source-code/](http://en.support.wordpress.com/code/posting-source-code/).
   Does anyone actually know what it takes to get that to work properly? (and also
   why the link in the credit section doesn’t point to what it says it points to)?
   Which plugin does it really need?
 *  Thread Starter [plnelson](https://wordpress.org/support/users/plnelson/)
 * (@plnelson)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/shortcodes-and-source-code/#post-1844335)
 * **I Got It Working !!**
 * . . .
    . . . but I don’t know how.
 * I was experimenting around to see if SH-E was interacting with other plugins 
   on my blog so I disabled Preserve Code Formatting. When I did that SyntaxHighlighter
   Evolved displayed the XML correctly! But I couldn’t leave Preserve Code Formatting
   disabled because it would break my whole blog – I use it everywhere. So I reactivated
   it expecting that SH-E would be broken again but it seems to still be working.
 * I’ve made a blog entry (with an artificial date so it would be buried in the 
   past) to test/monitor the situation. It recounts the whole sorry tale. [Here](http://blog.nelsondev.net/?p=247)
 *  [Khang Minh](https://wordpress.org/support/users/oddoneout/)
 * (@oddoneout)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/shortcodes-and-source-code/#post-1844340)
 * Hi, glad you got it working! I’m sorry about my previous post.
 * It was funny that I was going to tell you to try disabling that plugin, because
   there’s no way SH-E would mangle your code (unless you use the visual editor,
   which only happens if you use ancient version of SH-E by the way).
 * So now when you post a new blog post with SH-E everything’s fine? What kind of
   html are you using before installing SH-E that you are afraid of losing? Maybe
   a parse through all post contents might help.
 *  [korven](https://wordpress.org/support/users/korven/)
 * (@korven)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/shortcodes-and-source-code/#post-1844615)
 * This happened for me too.
 * No visual editor involved, in fact, I just imported my blog from WordPress.com
   via the XML import to a self-hosted blog.
 * As soon as I installed SyntaxHighlighter Evolved, all my source code broke and
   started displaying with HTML entities. Disabling the plugin makes it go back 
   to being normal.
 * There is definitely something faulty with the plugin.
 *  [korven](https://wordpress.org/support/users/korven/)
 * (@korven)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/shortcodes-and-source-code/#post-1844616)
 * On further inspection, it seems that the XML export from WordPress.com replaces
   characters in [sourcecode] blocks to HTML entities. This is what causes them 
   to be displayed incorrectly.

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘Shortcodes and source code’ is closed to new replies.

## Tags

 * [source-code](https://wordpress.org/support/topic-tag/source-code/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 14 replies
 * 5 participants
 * Last reply from: [korven](https://wordpress.org/support/users/korven/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/shortcodes-and-source-code/#post-1844616)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
