貌似这功能早在WP2.5已经支持,详细的描述请看:http://codex.wordpress.org/Shortcode_API

此文不解释原理(因为俺也说不清),就直接说具体的应用:

一、MP3播放器

1.添加:把以下代码复制至functions.php(注意在php循环内),然后下载mp3player.swf并放至主题根目录,MP3默认不自动播放

 
function mp3player($atts, $content=null){
 
	extract(shortcode_atts(array("auto"=>'0'),$atts));	
 
	return '<embed src="'.get_bloginfo("template_url").'/mp3player.swf?url='.$content.'&amp;autoplay='.$auto.'" type="application/x-shockwave-flash" wmode="transparent" allowscriptaccess="always" width="400" height="30">';
 
}
 
add_shortcode('mp3','mp3player');

2.使用:撰写文章时在“HTML模式”下插入以下格式代码即可

 
[mp3]MP3文件URL[/mp3]

自动播放代码格式:

 
[mp3 auto="1"]MP3文件URL[/mp3]

3.演示:

 
[mp3]http://storage.live.com/items/6E6B92BD0BA88634!163?filename=L.O.V.E.mp3[/mp3]

[mp3]http://storage.live.com/items/6E6B92BD0BA88634!163?filename=L.O.V.E.mp3[/mp3]

二、Google文档预览

1.添加代码:默认宽600高300居中显示

 
function docsGoogle($atts, $content=null){
 
	return '<p style="text-align: center;"><iframe style="border-style: none;" src="http://docs.google.com/viewer?url='.$content.'&embedded=true" width="600" height="300"></iframe></p>';
 
}
 
add_shortcode('docs','docsGoogle');

2.使用格式:目前Google文档查看器只“支持 PDF 文档、PowerPoint 演示文稿和 TIFF 文件”

 
[docs]Docs(.pdf、.ppt、.tiff)文件URL[/docs]

3.效果演示:

 
[docs]http://storage.live.com/items/6E6B92BD0BA88634!158?filename=how-to-build-your-own-web-site.pdf[/docs]

[docs]http://storage.live.com/items/6E6B92BD0BA88634!158?filename=how-to-build-your-own-web-site.pdf[/docs]

三、Flash快捷插入

1.添加代码:默认宽480高360居中显示

 
function swf_player($atts, $content=null){
 
	return '<p style="text-align: center;"><embed type="application/x-shockwave-flash" width="480" height="360" src="'.$content.'"></embed></p>';
 
}
 
add_shortcode('swf','swf_player');

2.使用格式及效果:

 
[swf]http://immmmm.com/download/chatnoir.swf[/swf]

[swf]http://immmmm.com/download/chatnoir.swf[/swf]

四、待添加……