duanchazhou6779 2015-03-13 17:44
浏览 48
已采纳

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

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条回答 默认 最新

  • douzhao2047 2015-03-13 20:08
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题