PHP Wordpress,何时放置运行时的代码

我跟着本指南,介绍如何禁用运行cron作业并运行它的标准Wordpress方法 在一段时间间隔,但我不知道在cron作业运行时将代码放在我希望运行的代码的哪个位置。 现在我想运行的代码是在functions.php中,我不认为它是在cron作业设置的间隔调用的。 我100%确定cron作业也是正确设置的,每15分钟一次。</ p>

换句话说,我每15分钟运行wp-cron.php的cron作业而不是 Wordpress使用的标准'vrtiaul cron'方法。 将代码放在wp-cron.php中似乎不起作用,我想在cron作业运行时运行一些代码。 我在哪里放代码?</ p>
</ div>



I followed this guide on how to disable the standard Wordpress method of running cron jobs and running it at an interval, but I do not know where to put the code for what I want to be ran when cron jobs runs. Right now the code I want to run is in functions.php and I do not think it is being called at the interval that cron job is set for. I am 100% sure that cron job is set up right, too, for every 15 minutes.

To rephrase, I have cron jobs running wp-cron.php every 15 minutes instead of the standard 'vrtiaul cron' method Wordpress uses. Putting code in wp-cron.php doesn't seem to work and I want to run some code when cron job runs. Where do I put the code?


I figured out a work around. Hopefully it will help any newbies in the future that find themselves in a similar situation. Since I couldn't figure out how to make an event and deal with all of that jazz, I just made a cron job to visit the site which calls the standard elements, so I just put my custom code in functions.php. This is the cron job code

wget -q -O - >/dev/null 2>&1

Feels like I am missing a lot of knowledge and it might give me slightly wrong information for Google Analytics in the future, but it works and requires no coding.

Csdn user default icon