我在哪里保存 WordPress 的小部件代码?
我在谷歌上搜索了很多,但似乎找不到应该在哪里保存我创建的小部件的代码。有点莫名其妙。
那么,谁能告诉我应该在哪里保存我的小部件?
谢谢, 约翰.
I've googled around quite a lot, but can't seem to find where I should be saving the code for the widget I've created. It's a bit baffling.
So, can anyone tell me where I should save my widget?
Thanks,
John.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要将小部件代码放入当前主题的functions.php 文件中或插件中。为了将其放入插件中,请在插件文件夹中创建一个新文件夹,并使用您在该文件夹中创建的文件夹的名称创建一个 .php 文件。在该文件中,使用以下代码启动您的插件:
显然,将值更改为对您的插件有用的值。然后,您可以将小部件代码粘贴到此文件中,它应该可以使用了。
资料来源:
http://codex.wordpress.org/Writing_a_Plugin
http://codex.wordpress.org/Plugin_API
You need to put your widget code in either the functions.php file of your current theme, or within a plugin. In order to put it in a plugin, create a new folder in the plugins folder and create a .php file with the name of the folder you created within that folder. In that file, use this code to start your plugin:
Obviously, change the values to something useful for your plugin. You can then paste your widget code into this file and it should be ready to use.
Sources:
http://codex.wordpress.org/Writing_a_Plugin
http://codex.wordpress.org/Plugin_API
据我所知,小部件(即插件)位于您的 wp-content/plugins 文件夹中,例如。 wp-content/plugins/您的小部件/
这是您需要的吗?
As far as I know, widget (ie plugins) go in your wp-content/plugins folder eg. wp-content/plugins/YOUR WIDGET/
Is that what you need?
您可以将代码保存在 wp-content\themes\YOUR-THEME-NAME\functions.php 文件中。
You can save your code in the file of wp-content\themes\YOUR-THEME-NAME\functions.php.