在 WordPress 博客上插入新主题时的附加操作
我在本地计算机上安装了 WordPress 博客。
我有一个 PHP 代码片段。该代码独立于 WordPress 代码,它作为原生 PHP 片段工作。
我的期望是:每当我的博客中插入新主题时,该代码片段都会作为添加额外的活动来运行。
问题是我对 PHP 的了解不多,所以我不知道插入新主题时会运行哪个操作。我应该在哪里插入这个 PHP 片段?
请帮我。 谢谢你!
I have WordPress blog installed on my local machine.
I have a PHP code fragment. This code is independent with WordPress code, it works as a native PHP fragment.
My expectation is: Whenever a new topic is inserted into my blog, that code fragment run as adding a extra activity.
The problem is I don't have much knowledge in PHP, so I don't know which action is run when a new topic is inserted. Where do I should insert this PHP fragment?
Please help me.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看 WordPress 的 Hooks &过滤器: http://codex.wordpress.org/Plugin_API#Hooks.2C_Actions_and_Filters
基本上,这些允许您在 WordPress 事件发生时调用自己的自定义函数,因此您可以将 PHP 代码片段放入自定义操作或过滤器中,然后找出哪个 WordPress 事件应该触发它。您说“每当插入新主题时”……不确定这是否意味着发布新类别或发布新帖子,但几乎所有内容都有一个钩子。这是一个参考:http://adambrown.info/p/wp_hooks/hook
Take a look at WordPress's Hooks & Filters: http://codex.wordpress.org/Plugin_API#Hooks.2C_Actions_and_Filters
Basically, these allow you to call your own custom functions when a WordPress event happens, so you'd put your PHP code fragment into a custom action or filter, then figure out which WordPress event should trigger it. You said "whenever a new topic is inserted"...not sure if that means a new category is posted or a new post is published, but there is a hook for just about everything. Here's a reference: http://adambrown.info/p/wp_hooks/hook