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've already read what I can on a couple of sites and installed this plug-in: http://en.support.wordpress.com/code/posting-source-code/ http://alexgorbatchev.com/SyntaxHighlighter/

I'm missing how to make it work. Question 1: Do I have to type in the Visual window or the HTML window? Question 2: Does TinyMCE mess with this? I've seen my code disappear in the HTML window.

I currently have typed in my code in Visual Window like this:

[sourcecode language="php"]
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://CMSTrainingVideos.com" );
if ($_GET["page_id"] == 1)
   Header( "Location: http://CMSTrainingVideos.com/?p=35");
if ($_GET["page_id"] == 2)
   Header( "Location: http://CMSTrainingVideos.com/?p=43");
?>
[/sourcecode]

I also tried <pre language="php"> with the "Geshi" syntax highligher, and no luck there either.

But nothing is happening, i.e. no syntax highlighting: http://cmstrainingvideos.com/?p=53

share|improve this question

3 Answers 3

up vote 2 down vote accepted

I use a similar plugin called WP Syntax, which works better, in my experience, so I'm going to answer for that one:

Question 1: Do I have to type in the Visual window or the HTML window?

In the HTML window. I prefer the <pre lang="php"> mode.

Question 2: Does TinyMCE mess with this?

Yes, it will html encode special chars, for example transforming => into =&gt; etc. so you should probably disable the rich editor alltogether.

share|improve this answer
    
Thanks, finally got it to sort of work. It looks really ugly though - like the styles are not being picked up correctly. cmstrainingvideos.com/?p=53 Any suggestions now? Before, I was actually losing code when I put it in the HTML editor, but maybe when it is in the <pre> tag, it preserves it. –  NealWalters Jan 31 '11 at 0:22
    
You have some conflicting CSS from the Twentyten theme. You can right-click -> Inspect element using Firefox + Firebug or Chrome to sort it out. –  scribu Jan 31 '11 at 3:35

http://wordpress.org/extend/plugins/visual-code-editor/ prevents the code wrangling:

first put the sourcecode tags, then mark it as pre, then copy your code in between, it will not HTML encode the stuff.

So you do not have disable your Visual Editor anymore.

share|improve this answer

I have been installing and removing many plugins to highlight my code on my blog.Finally, I managed to use Prettify GC Syntax Highlighter effectively.

I also posted step by step configuration and usage guide for the plugin here

Be warned though, tinyMCE will mess codes with Prettify GC Syntax Highlighter as well. If you plan to include codes in your posts, get used to the HTML editor, not the visual editor.

share|improve this answer

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.