【发布时间】:2013-12-10 22:31:00
【问题描述】:
我知道如何在特定 wordpress 主题的 functions.php 中创建自己的简码。有没有办法创建独立于使用的主题的全局短代码?
【问题讨论】:
-
短代码功能不限于functions.php。你也可以加入插件。
标签: php wordpress wordpress-theming shortcode
我知道如何在特定 wordpress 主题的 functions.php 中创建自己的简码。有没有办法创建独立于使用的主题的全局短代码?
【问题讨论】:
标签: php wordpress wordpress-theming shortcode
修改 shortcode_handler 函数以进行投标
/*
Plugin Name: Shortcode Plugin
Plugin URI:
Description: My Global Shortcode
Version: 1.0
Author:
Author URI:
*/
//register [my-custom-global-shortcode]
add_shortcode("my-custom-global-shortcode", "shortcode_handler");
// the function called with the shortcode
function shortcode_handler() {
$html = '<div>Hello World!</div>';
return $html;
}
?>
【讨论】: