Use cron to create a non blocking task

For instance, since the configured cron tasks will only be run on page load, the task might not be run at the desired interval if there are no visitors. To prevent this, you need to use your operating system’s task scheduler. For this, you need to define define(‘DISABLE_WP_CRON’, true); in your wp-config.php file. After that, … Read more

WordPress function, Run using Crontab

define(‘DISABLE_WP_CRON’, true); This line disables the default behaviour of WP Cron. Which is being triggered by a user that visits the site. This is bad for a couple of reasons (nobody might visit, tasks are started via apache handler instead of PHP CLI, …). Now, if you have disabled it, you need another way to … Read more

How to set intervals in cron jobs?

You can do this via wp_cron by using the following, function more_reccurences() { return array( ‘sixhourly’ => array(‘interval’ => 21600, ‘display’ => ‘Every 6 hours’), ); } add_filter(‘cron_schedules’, ‘more_reccurences’); then find the function that does the autopost and call it by if ( !wp_next_scheduled(‘autopost_function’) ) { wp_schedule_event(time(), ‘sixhourly’, ‘autopost_function’); } If you want to use … Read more

Generate Email if No Posts Within Time Period

You’ll need to set up a cron job that checks once a day to see if the latest post is more than seven days old. So, some where in a plugin file. Schedule a new event. Then hook into that event. Grab the post date, turn it into a unix time stamp, and compare that … Read more

How to do some action weekly?

Did you try this plugin? http://wordpress.org/extend/plugins/scheduled-post-delete/ //// Sorry for my mistake, I understood you wrong. Try by pasting this in your functions.php: function auto_cat_remove() { global $post; wp_schedule_single_event( time() + 604800, ‘remove_news_cat_event’, array( $post->ID ) ); } function remove_news_cat_func( $post_id ) { global $wpdb; $category_id = get_cat_ID( ‘news’ ); $wpdb->query( $wpdb->prepare( “DELETE FROM $wpdb->term_relationships WHERE … Read more

How to use wp cron job to run a function

First of all you have to remember how WP cron works. The action will trigger when someone visits your WordPress site, if the scheduled time has passed. So if your site isn’t very crowded at 3am, the cron job won’t start exactly at 3am. (You should use real cron if you really need to run … Read more

Cancel/Stop a currently ongoing scheduled cron event?

Removing / un-scheduling obsolete cron jobs can be achieved using this code snippet. add_action(“init”, “remove_cron_job”); function remove_cron_job() { wp_clear_scheduled_hook(“my_schedule_hook”); } Change the my_schedule_hook to cron’s hook name and add the code in your theme’s function.php file.

Avoiding “Missed Schedule” errors when inserting future posts

The missed schedule warning comes form those lines: https://github.com/WordPress/WordPress/blob/f884d7973b052c3efe0901bb136b9898ece8aa39/wp-admin/includes/class-wp-posts-list-table.php#L998,L999 It should be independent on any cron event, as the warning is being displayed only in case the current UTC time – post_date_gmt > 0 – there is no other condition (except for post having the future status). In order to debug the issue, check what … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)