在 WordPress 博客上插入新主题时的附加操作

发布于 2025-01-05 20:35:29 字数 220 浏览 3 评论 0原文

我在本地计算机上安装了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以酷 2025-01-12 20:35:29

看看 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文