Custom WordPress shortcode functions

Here is an example of creating shortcode for your wordpress blog,   this is a simple use of shortcodes and you can write much more complex shortcodes when required.
[sourcecode language="php"]</pre>
//[yearsExperience]
 function yearsExperienceFunction()
 {
 $date1=new DateTime("now") ;
 $date2=new DateTime("1990-1-1");
 $date= $date1->diff($date2);
 return $date->format('%y');
 }
 add_shortcode( 'yearsExperience', 'yearsExperienceFunction' );

[/sourcecode]

 This shortcode writes out the number of years since a given date, this function can be added to your funcitons.php file and its hook add_shortcode registers the function for use, you can then call the function from within your post.
[sourcecode language="php"][yearsExperience][/sourcecode]



For more information on shortcodes please visit http://codex.wordpress.org/Shortcode_API