在新帖子上执行命令

在新帖子上执行命令

本文介绍了Wordpress - 在新帖子上执行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的服务器上安装了 localhost 的最新 WordPress 版本,并且已经开始设计我自己的插件,但我想首先了解更多关于 WordPress 的工作原理.

I have a localhost installed version of the latest WordPress on my server, and have begun designing my own plug, but am trying to learn a bit more about how WordPress works first.

我目前正在寻找一种每次创建新帖子时执行终端命令(或仅运行在服务器上的应用程序)的方法.如果可能的话,最好根据帖子所在的类别运行不同的命令.这样的事情可能吗?提前致谢!

I'm currently looking for a method to execute a terminal command (or just an application that runs on the server) every time a new post has been created. Even better if possible, to run a different command depending on what category the post was made in. Is something like this possible? Thanks in advance!

推荐答案

尝试编写函数并使用带有 publish_post 的动作钩子,如下所述 http://codex.wordpress.org/Plugin_API/Action_Reference

Try writing the function and using the action hook with publish_post as described here http://codex.wordpress.org/Plugin_API/Action_Reference

所以它会是这样的:

<?php
    function my_custom_function(){
        //stuff to do on new post
    }
    add_action('publish_post', 'my_custom_function');
?>

希望这会有所帮助.我不确定终端执行情况,但 @thenetimp 似乎对此有所了解.

Hope this helps. I am not sure about the terminal execution but @thenetimp seems to have a handle on that.

这篇关于Wordpress - 在新帖子上执行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 06:46