How to highlight code syntax in WordPress

Published on May 22, 2010

WP-Syntax is the answer.

For example, this is how I highlight an iPhone’s Objective-C code in this post.

- (void)viewDidLoad   
{    
    [super viewDidLoad];    
    NSString *title = [NSString stringWithFormat:@"My %@ syntax", @"AWESOME"];    
    self.title = title;    
}

 

To use WP-Syntax, simply surround the code with <pre lang=”LANGUAGE”> and </pre>, where LANGUAGE is the programming language.

To find out what to use for LANGUAGE, look under supported languages here. </pre> </pre>