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?

1个回答

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 - http://yoursite.com >/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
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问