我知道如何在特定wordpress主题的functions.php中创建自己的快捷代码。有没有一种方法可以创建独立于使用中的主题的全局快捷方式?
- 在wp-content/plugins/my自定义全局短代码中创建my-custom-global-shortcode.php/
- 将此代码粘贴到该文件中,您就拥有了一个有效的全局快捷代码
-
修改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; } ?>