How can I change the frequency of a scheduled event?

It looks for me that you are adding this event only when there is no such event ‘send_email_alerts_hook’ scheduled yet. Try something like this and let me know if it workded. function shedule_email_alerts() { if ( !wp_next_scheduled( ‘send_email_alerts_hook’ ) ) { wp_schedule_event(time(), ‘daily’, ‘send_email_alerts_hook’); } else { wp_reschedule_event(time(), ‘daily’, ‘send_email_alerts_hook’); } } The thing is … Read more

Need a function for changing saved post_date or post_date_gmt to relative time in wordpress

Straight from my framework as human_time_diff() involves caching. /** * Time since an entry was posted * * Adapted from binary bonsai * @link http://binarybonsai.com/code/timesince.txt * @license unknown – original source unavailable * * @todo check human_time_diff(); as a replacement * @link http://codex.wordpress.org/Function_Reference/human_time_diff * Note: Rarst said there’s caching involved with this fn. * * … Read more

How to Add a .js file Only in one specific Page Dynamically to Head

Use conditional is_page() for loading script on specific page. Here Is The Modified Version of Your Function: //Load Scripts function load_scripts(){ wp_deregister_script(‘jquery’); // De-register Existing jquery wp_register_script(‘jquery’, ‘http://code.jquery.com/jquery.js’, ”, ”, true); wp_enqueue_script( ‘jquery’ ); wp_register_script(‘bootstrap-jquery’,get_template_directory_uri().’/assets/js/bootstrap.js’, array( ‘jquery’ ), ”, true); wp_enqueue_script( ‘bootstrap-jquery’ ); // register the script wp_register_script( ‘my-script’, ‘URL to Script’ ); // by … Read more

Problem creating cron job wordpress

Here’s the minified reference I use for setting up WordPress cron, which is all from wp_schedule_event() and cron_schedules: Setup Cron // SETUP CRON add_action(‘wp’, ‘myplugin_schedule_cron’); function myplugin_schedule_cron() { if ( !wp_next_scheduled( ‘myplugin_cron’ ) ) wp_schedule_event(time(), ‘daily’, ‘myplugin_cron’); } Cron Function // the CRON hook for firing function add_action(‘myplugin_cron’, ‘myplugin_cron_function’); #add_action(‘wp_head’, ‘myplugin_cron_function’); //test on page load … Read more