AKA Marketing.com Logo

Blogged thoughts, is our web blog. Expect views, opinion, rants and tirades about everything and anything 

« Home / Services / Forums »         Organic Search Engine Optimization (SEO) Solutions. Call now on +00-353-879807629

Subscribe to our SEO / IT related blog by entering your email address below

Blogged thoughts

| by the www.akamarketing.com team



Inserting Code into Wordpress

I’ve shed many tears over the years (I’m a poet, I just don’t know it) when trying to insert code samples into my Wordpress blog posts. Wordpress users who cover technical topics will have shared in my pain and will know exactly what I mean. I therefore feel obliged to let people know about a Wordpress plugin called Code Snippet which I recently discovered and installed. Code Snippet which is available for download at http://wordpress.org/extend/plugins/codesnippet-20/ enables bloggers to post color highlighted code (with optional line numbering) in their posts without fear of it being mangled or hidden by Wordpress. It runs off the GeSHi engine which is generic syntax highlighter which supports a tonne of programming and markup languages.

The installation of Code Snippet is extremely easy. You basically just need to upzip the archive to your desktop, upload it to the wp-content/plugins folder of your overall Wordpress installation folder and then activate it from the ‘Plugins’ tab from within Site Admin. To actually use the plugin you wrap code in code blocks illustrated by the below image.

Code Snippet Code Blocks

You replace the value of the lang attribute with the language your code is written in such as HTML or c#. Below is an example of some PHP code displayed via Code Snippet.

  1. $ufun = “$dfunction”;
  2. switch ($ufun) {
  3.  case $ufun=“Edit”:
  4.  //go to Spoono
  5.     //Header ("Location: ./editor.php?filename=$filename&ffunction=$ffunction");
  6.  include(“editor.php”);
  7.  break;
  8.  
  9.  case $ufun=“dDelete”:
  10.  echo “delete a dir”;
  11.  //Header ("Location: ./delete.php?filename=$filename&ffunction=$ffunction");
  12.  include(“delete.php”);
  13.  break;
  14.  
  15.  case $ufun=“dRename”:
  16.  //echo "Rename was selected";
  17.  include(“rename.php”);
  18.  break;
  19.  
  20.  case $ufun=“dCopy”:
  21.  //echo "Copy was selected";
  22.  include(“copy.php”);
  23.  break;
  24.  
  25.  case $ufun=“dMove”:
  26.  //echo "Move was selected";
  27.  include(“move.php”);
  28.  break;
  29.  
  30.     case $ufun=“dDownload”:
  31.  //echo "Download was selected";
  32.  include(“download.php”);
  33.  break;
  34.  
  35.  case $ufun=“dOpen”:
  36.  //echo "Download was selected";
  37.  include(“filemanager.php”);
  38.  break;
  39.  
  40.  default:
  41.  echo “You should not be here”;
  42.  }
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • Digg
  • Furl
  • YahooMyWeb
  • Reddit
  • Simpy
  • De.lirio.us
  • StumbleUpon
  • Technorati
  • Netscape
  • Spurl
  • blogmarks
  • blinkbits
  • SphereIt
  • Slashdot
  • Ma.gnolia
Leave a Comment
Name:
Email:
Website: