如何在WordPress中使用简码(shortcodes)

作者:     目录: PHP+MySQL     发表: 2010年01月14日

从WordPress 2.5开始支持简码shortcodes,以便简洁方便的调用函数[shortcode]。

1. 在functions.php中添加简码函数

function welcome()
 {return 'Welcome to <a href='http://renniaofei.com'>RENNIAOFEI</a>"; } 

2. 在functions.php中,使用add_shortcode() 函数,增加下面代码。

add_shortcode('wel', 'welcome');

3. 简码(shortcodes)使用方法

[wel]

使用上述代码后输出内容:

<a href=’http://renniaofei.com’>RENNIAOFEI</a>

发表评论