Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [wp-cron]

wp-cron refers to a WordPress subsystem that allows for the scheduled execution of code

0
votes
1answer
11 views

Call do_action() within WordPress cronjob

I've programmed a cronjob in WordPress which get's executed every 5 minutes. In the function of the cronjob im trying to perform a do_action: error_log('Send Email'); do_action( '...
0
votes
0answers
18 views

Use a cron job to automatically create posts based on dates

I have a custom post type called cpt1. I need to run a function that on a daily base Loops through cpt1 and then check the dates. This is done by using cron job to trigger. Within this loop ...
0
votes
2answers
23 views

Scheduling WP cron jobs

I am new with cron jobs and I have to schedule cron jobs. There are a lot of cron jobs in my website which are running randomly but I want all these to run at specific time. Actually I do not want ...
0
votes
0answers
21 views

Php cron job (wp-cron) not working

I try to create a php cron job with help of the WP Control plugin. The purpose is to delete all files in the uploads directory for the current year and month. I use this code: $files = glob('./wp-...
0
votes
1answer
16 views

Media Library Latency, Lag, CRON?

When I add images to my Media Library they aren't available in the Media Library for about an hour. It seems like there is a queue or some sort of CRON that fires. The image appears in the media ...
0
votes
1answer
8 views

Automated mark posts as featured every day

Hello Wordpress Community, I want to build myself a "recipe of the day" functionality. I'm looking for a way to mark 3 Custom Post Types per day as "Featured Posts" by a plugin or Cronjob. The ...
0
votes
1answer
25 views

Check if event was scheduled - schedule event only once

I have some programming error in my wordpress plugin. When its running, then it keeps registering cron job to the wordpress. I wrote the plugin as a class: class Cleverstart_Woofio extends ...
0
votes
1answer
22 views

Run function at a specific time of a day

I have tried this solution but I can't get it to work Run function at specific time Here is my example: //this is for testing purposes function my_cron_schedules($schedules){ if(!isset($schedules["...
0
votes
2answers
52 views

Use WP Cron to Clear a Page Cache?

I'm using a plugin (Comet Cache) to save static versions of a particular page I have on my site. Inside the plugin, I have the cache set to clear every 2 hours (that way this page can show the ...
0
votes
1answer
25 views

Most efficient way to trigger wp-cron through system cron.

I have recently decided it would be best if i disable the built in wordpress cron function and move to the system cron which will activate the wordpress cron every 15 minutes. I am wondering which ...
0
votes
1answer
11 views

wp_get_schedule and wp_next_scheduled don't find my scheduled wp-cron job

I have tried the following two approaches, each resulting that the cronjob gets added over and over again, until I remove the code. I literally had it scheduled hundreds of times... if(!...
3
votes
2answers
32 views

WP CRON runs only the first time

Here is my code function cron_add_weekly( $schedules ) { $schedules['seconds'] = array( 'interval' => 5, 'display' => __( '5 Seconds' ) ); return $schedules; } ...
0
votes
1answer
21 views

Where in the page load code is wp-cron triggered?

I just spent way too much time trying to troubleshoot why my wp-cron job wasn't running. It seems, under 4.9.8, the only way to run cron is by calling the wp-cron.php file as a URL. The docs say ...
1
vote
1answer
47 views

Detect if Cron is Running

Many times I have code and I want to make sure it only runs in a cron context, or it never runs in a cron context. Is there an is_cron_running style function?
0
votes
1answer
29 views

wp_set_post_terms not updating with WP Cron Event

I have a jobs board custom post type (job_listings) with a taxonomy (cvl_job_status) attached with various tags assigned, namely; Live, Filled and Expired. Each job post has a custom field (...
0
votes
1answer
21 views

WP_CRON issue with UTC and local time

I have made a plugin to change some user metadata on a schedule according to the wp_cron function. If the current time is say between their lunch hours (that is in their user profile as date('g:i a', ...
1
vote
1answer
66 views

Sync user meta fields using Wp cron job

I'm searching about using wp cron job to sync two user meta fields monthly. I'm using a very awesome plugin called "SyncFields" and it works fine automaticaly, But I'm looking for sync it every month.
0
votes
0answers
57 views

Can run cron event manually with WP-CLI but not with any plugin, unsure if it's being scheduled

I have a cron event that I am able to manually run with wp cron event run --all When I go to my dashboard and go to WP-Crontrol OR Advanced Cron Manager, I can see my event listed and tell it to ...
0
votes
1answer
60 views

Wordpress Cron job, 302 response

I am trying to debug a cron job in wordpress. It's supposed to update user hours but doesn't, and after putting some test statements in the code, I'm not too sure it's even running. I have debug ...
0
votes
0answers
39 views

Cron job cannot use “wp_remote_post”

I've written a script that is running once an hour on my site but it's not working. I've been trying to debug and unfortunately I haven't gotten very far. I'm getting the following error: Uncaught ...
0
votes
1answer
46 views

wp_split_shared_term_batch messing up upgraded ACF 5 data

After upgrading Wordpress and associated plugins to the latest version on a dev server and migrating the source files and database to the production server, the data from ACF is different. prod and ...
0
votes
2answers
47 views

How to Trigger WP CRON at Local Timestamp?

I am trying to schedule WP Cron that should run every midnight at Local Timestamp, but it is taking UTC only. This the code I am trying with, if ( ! wp_next_scheduled( 'midnight_cron' ) ) { $...
0
votes
2answers
71 views

WP cron and update post meta

I try to create a scheduled cron job which runs every hour, Its my first time working with wp-cron. In the cron function, I want to update post meta values, if some conditions are met. I also tested ...
0
votes
1answer
125 views

Wordpress function, Run using Crontab

I have disabled cronjobs on my nginx server, as it is better to run from crontab. define('DISABLE_WP_CRON', true); How could I run a custom wordpress function using Crontab, once per day? This ...
0
votes
1answer
38 views

Cronjob function not executed - negative seconds

I've created a custom function that read an XML file and import it in woocommerce products. The XML files are exported by an external platform every day in the website ftp. I replaced the wordpress ...
1
vote
0answers
34 views

WP-CLI cron on multisite using WP-Toolkit “succeded”, but callback not executed

I'm trying to trigger WordPress crons within a multisite using Plesks WordPress toolkit. Generally it is working, but the callback doesn't seemed to be executed. The command to execute crons: /...
0
votes
1answer
39 views

Wordpress cronjob get scheduled but function does not run

I am trying to schedule wordpress cron job having dynamic hooks. I am developing a plugin and the cron jobs are to be scheduled dynamically. I need a way to name the hooks that directly corresponds to ...
0
votes
2answers
40 views

How to make sure WP-CRON job loops through all posts?

I am using WP-Crontrol and have some CRON jobs running daily to check the age of the posts. If the post is 2 days older, they will be deleted. This works but for some reason, only some of the three ...
3
votes
2answers
203 views

WP Cron - Run Cron after evey 15 minutes at a specific time for the next three hours

In WordPress I want to schedule an Event which will run my function (hook) at a specific time (let's say at 6PM) and then it will run again after 15 minutes (means at 6:15 PM) and keep running after ...
0
votes
0answers
46 views

WP Cron JOb - Publish Post when URL is available Else Schedule a new Cron Job

I wanted to achieve the following. I will create cron job in wordpress (i am using wp_schedule_single_event) The callback function of hook will check if URL (which i will provide) is available. ...
0
votes
0answers
22 views

Add lines to wp-config.php file for disabling wp cron job automatically

Is it possible to add lines to wp-config.php with some codes inside theme (like may be on theme activation) i want add the below code without editing the wp-config file manually define('...
1
vote
0answers
120 views

cron.php being constantly deleted [closed]

I have a problem with a WordPress installation (even a fresh one), one and only one server. The cron.php file is being deleted in a random time. The site had an infection but it was reinstalled ...
1
vote
1answer
18 views

Is there way to run a code every time when any cron is run?

publish_post is an action triggered whenever a post is updated and its new status is "publish". Is there similar action which is trigger when cron is run including WordPress default crons? I am ...
2
votes
0answers
36 views

Scheduling posts on wordpress adds wrong seconds as post_date

When scheduling a post in wordpress, e.g. 15:50, I always see that as time there are always seconds added at the end, e.g. 15:50:48, which ruins my cronjobs and makes them run 1 minutes later (if I ...
7
votes
1answer
388 views

How to make sure that only one wp_cron() runs at a time?

I have around 20 wp_cron() functions like the following code. Almost all crons run hourly; a few are daily. if ( ! wp_next_scheduled( 'my_task_hook' ) ) { wp_schedule_event( time(), 'hourly', '...
0
votes
0answers
63 views

WordPress Multisite cron jobs using cron tab

U have a WordPress multisite install with subfolders. U'm trying to set up cron jobs. I know I can setup for each site with, HTTP_HOST=sub.example.com php wp-cron.php > /dev/null But this doesn't ...
0
votes
0answers
96 views

Run external file cron using WordPress Scheduler

I am using a WordPress store where I am importing products and categories from external API. Procedure for each files have created in external files. Earlier I used cpanel to assign those crons like ...
0
votes
0answers
32 views

If planning a new post, each URL gets a “/?doing_wp_cron=1234…”

unfortunately I realise that each URL from my wordpress site (actual WP version) gets a "/?doing_wp_cron=1234..." at the end if I planned a new post for public it some times later. What could cause ...
1
vote
0answers
542 views

WordPress Cron is scheduled but not running

I'm writing a plugin that uses WordPress Cron. Here the code I am using to add and remove the cron event. On plugin activation it creates the cron event, and on plugin de-activation it removes the ...
0
votes
1answer
244 views

Setup wp_schedule_event within a custom plugin

I am using WordPress 4.9.6 and I am trying to create a plugin that pulls data from an external API. See below my current code: myPlugin.php <?php /** Plugin Name: myPlugin description: Get Data ...
0
votes
0answers
34 views

Plugin with functions inside a class & how to trigger WP CRON

Another developer has created a plugin for me that imports some data from an XML feed, before it imports it runs a function that deletes the existing items, then runs the import function. These both ...
0
votes
1answer
288 views

How to use wp-ajax in wp-cron

I have create a custom wordpress plugin where i am using wp ajax. In class's __construct i have an action (admin_footer) in order to use wp_enqueue_script and wp_localize_script following wp ...
0
votes
2answers
125 views

Better way to run heavy scripts using WordPress database

I am going to make plugin, collecting post views from Google Analytics. The main idea is to get views per post and store them with post meta. Problem: My blog has a lot of posts and google analytics ...
0
votes
1answer
149 views

wp-cron and execution of code in is_admin() included script

I am developing a plugin. Among other things its backend settings will allow admins to update a site data file from a 3rd party data provider, or to switch on/off a wp-cron job to do this ...
1
vote
1answer
65 views

Use wp_set_post_terms() instead of wp_insert_post()

Since I use cron jobs for automation I ran into some problems with the taxonomy. Before I used the cron job, the following code used to work: $custom_tax = array( "project-type" => array( ...
0
votes
1answer
39 views

Code does not work in class implementation but works fine in functions.php file

I am trying to clean up my codes and separate them in class files. I have this block of code that works perfectly fine where it sets the status of events older than a week to trash when I add it in ...
0
votes
0answers
400 views

Constant WP_CRON_LOCK_TIMEOUT already defined in /htdocs/wp-config.php

I got this PHP error : Notice: Constant WP_CRON_LOCK_TIMEOUT already defined in /htdocs/wp-config.php on line 195 I don't understand because when I do a search in the wordpress project with the ...
0
votes
1answer
93 views

Use cron to create a non blocking task

I'm writing a plugin which collects a pretty large feed. From each feed item a custom post will be created. The feed can also contain images for each item that is uploaded from the remote url. ...
1
vote
0answers
43 views

How does task scheduler plugin implements cron that is not dependent on page load request? [closed]

I have been looking at task scheduler Plugin that claims to run cron task at a fixed interval without depending on page load request. Can anyone help me understand how it does the same?
1
vote
1answer
87 views

Is there any background process that I can run from plugin without depending on page hits on a website without affecting page-load speed?

I am developing a WordPress plugin and wants to run a background task that calls an API and updates database table. Now, the API can only give results for 5 DB entries in one go and for 500 entries in ...