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

Ras*_*lam 0 wordpress shortcode

我想在wppb插件样板中添加简码,这是样板生成器的链接http://wppb.me, 请告诉它它将如何工作?对你的帮助表示感谢。

小智 6

遇到这种纠结,寻找完全相同的问题的解决方案,在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' );
}
Run Code Online (Sandbox Code Playgroud)

在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') );
}
Run Code Online (Sandbox Code Playgroud)

然后创建您的简码函数。

  • 这对我帮助很大。谢谢! (2认同)

uch*_*eng 1

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

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

另外,还有一个关于此的 github问题