如何在wppb插件样板中添加短代码

时间:2016-10-27 01:35:36

标签: wordpress shortcode

我想在wppb插件样板中添加短代码 这是样板生成器 http://wppb.me 的链接 请告诉它如何运作? 非常感谢您的帮助。

2 个答案:

答案 0 :(得分:4)

在此过程中寻找相同问题的解决方案,在github上找到了wordpress样板插件的解决方案:https://github.com/DevinVinson/WordPress-Plugin-Boilerplate/issues/262

private function define_public_hooks() {
    $this->loader->add_action( 'init', $plugin_public, 'register_shortcodes' );
}

在您的class-pluginName.php文件的define_hooks函数中(将其余的添加操作添加到上述操作中。

然后在您的class-pluginName-public.php文件中为短码创建register_shortcodes函数。

public function register_shortcodes() {
  add_shortcode( 'shortcode', array( $this, 'shortcode_function') );
  add_shortcode( 'anothershortcode', array( $this, 'another_shortcode_function') );
}

然后创建您的简码函数。

答案 1 :(得分:0)

在functions.php或插件中添加短代码没有区别。

请参阅Shortcode API以了解如何添加短代码。

此外,还有一个github issue