Hot answers tagged

37

You can create new schedule times via cron_schedules: function my_cron_schedules($schedules){ if(!isset($schedules["5min"])){ $schedules["5min"] = array( 'interval' => 5*60, 'display' => __('Once every 5 minutes')); } if(!isset($schedules["30min"])){ $schedules["30min"] = array( 'interval'...


14

I believe what you're referring to is called "Post Types". By default, WordPress has a complete post types you're already familiar with - post ( news / blog ), page ( Pages ), attachment ( Media ), revision ( Page / Post Revisions ). You can read up on the full list of built in post types on The Codex - Post Types. If you want to register a new Custom Post ...


7

Turns out I had to set the ALTERNATE_WP_CRON flag in wp-config.php to make this work: define('ALTERNATE_WP_CRON', true);


4

You can create a new plugin with the mce_external_plugins filter.. and link it to a js file. Then, in that file you can do your processing. function tinymce_init() { // Hook to tinymce plugins filter add_filter( 'mce_external_plugins', 'tinymce_plugin' ); } add_filter('init', 'tinymce_init'); function tinymce_plugin($init) { // We create a new ...


3

If your site does get heavy traffic then you could try using set_transient() to run it (very approximately) every 5 minutes, eg: function run_every_five_minutes() { // Could probably do with some logic here to stop it running if just after running. // codes go here } if ( ! get_transient( 'every_5_minutes' ) ) { set_transient( 'every_5_minutes',...


3

For anyone protecting their (development) site from public access, HTTP Authentication can be the cause of WP Cron not functioning. In case it can help anyone, here is my list of things I did before identifying and understanding the requirements of WP Cron: I noticed events were correctly scheduled and could be run using WP-CLI. And also noticed that ...


3

wp-cli is another way: Listing Events > wp cron event list +-------------------+---------------------+-----------------------+---------------+ | hook | next_run_gmt | next_run_relative | recurrence | +-------------------+---------------------+-----------------------+---------------+ | wp_update_plugins | 2020-04-14 08:11:38 | ...


3

I was able to cobble something together. I feel like there is a better approach to solving this, but that it might help to share my progress anyway. The main trick came from this answer by @Vladimir Lukyanov. My main concern with this solution is that the unselect event, "selection:unsingle", is triggered twice. I was unable to prevent this from happening. ...


3

It's not possible with just WordPress to schedule code to run in the background at a specific time. WordPress, like most (if not all) PHP web applications, only actually runs in response to a URL being accessed, and a request being made to the server. For a scheduled event to run at a certain time, you would need to have something running on the server, such ...


3

I would suggest first read the wordpress documentation about actions to understand how they work. Actions are aplit into two section, add_action and do_action do_action is the "location" where you hook into it. A basic example of do_action do_action('my_custom_action'); You can also pass arguments into do_action which can be available in ...


2

You need to schedule the event differently. In your approach, you hook to wp to schedule the event, meaning that it is called everytime WordPress is called, setting your option back. I am not quite sure if the schedule is postponed or if you create multiple schedules this way, but it is not correct. You should check if this event is scheduled (using ...


2

I've modified above function somewhat function get_event_list( $latest = true, $order = 'ASC', $return = false, $year ) { // Pass year i.e $year $enddate = strtotime($year."-12-31"); // year's last date $startdate = strtotime( ($year-1)."-12-31"); year's first date $yesterday = array($startdate, $enddate ); // Fetch posts between these dates $...


2

How to make Time.ly all-in-one event calendar mobile friendly Anyway, now down to the actual "mobile" part of things. After creating a wonderfully responsive website for Tahlequah Public Schools and installing this awesome calendar plugin, I found I had an issue with the site being mobile-friendly still... My calendar looked awful on mobile: it displayed ...


2

My solution for now is check every hour if it is running and if not reschedule it. I also remove this in deactivate etc. wp_schedule_event(time(), 'hourly', 'my_restart_schedule_if_failed'); function my_restart_schedule_if_failed() { if( !wp_next_scheduled( 'my_scheduled_minute_job' ) ) { wp_schedule_event( time(), 'one_minute', '...


2

The easiest way to create a custom post type in WordPress is by using a plugin. This method is recommended for beginner because it is safe and easy. For example : Custom Post Type UI The problem with using a plugin is that your custom post types will disappear when the plugin is deactivated. you can manually create your custom post type by adding the ...


2

You need a meta query. There's also documentation on ACF for querying dates. <?php $event = new WP_Query( array( 'post_type' => 'gacr-event', 'posts_per_page' => 5, 'orderby' => 'meta_value_num', 'order' => 'DESC', 'meta_query' => array( array( ...


2

You can trigger it in plugin activation instead of on each plugin call: //Add a utility function to handle logs more nicely. if ( ! function_exists('write_log')) { function write_log ( $log ) { if ( is_array( $log ) || is_object( $log ) ) { error_log( print_r( $log, true ) ); } else { error_log( $log ); ...


2

It likely does not have to do with WordPress Core - in most cases this type of issue comes about when plugins conflict. I would suggest deactivating all your other plugins and trying a default theme, a la Twenty Seventeen. If it works at that point, you can switch the theme & test, then activate one plugin at a time & test, until you find what's ...


1

I guess body.scrollTop is deprecated in strict mode. Please use documentElement.scrollTop if in strict mode and body.scrollTop only if in quirks mode. So I would suggest you to use document.documentElement.scrollTop. also let us know when are you using this statement? show us full code and your console error if possible Please try the below code edited ...


1

Your code runs on init which is well before the the_content filter is called. There is no reason you can't hook into it. It should be as easy as: add_filter( 'the_content', function ($content) use ($subsc_status) { return $content.' || '. $subsc_status; } );


1

The Cronjob Scheduler plugin allows you to run frequent tasks reliably and timely without anyone having to visit your site, all you need is at least 1 action and a Unix Crontab schedule. It's very easy to use, and very flexible. You create your own function, and define an action within it. Then you can choose your action from the plugin menu and fire it ...


1

I'm afraid that other than waiting for someone to visit your site which runs a function, the only other option is to set up a cron job on your server using something like this https://stackoverflow.com/questions/878600/how-to-create-cronjob-using-bash or if you have a cpanel style interface on your server, sometimes there is a gui for setting this up.


1

Thanks to Milo for helping me through this. Here is the code that worked for me. function custom_events_query( $query ) { if ( $query->is_main_query() && $query->is_archive && !is_admin()&& is_post_type_archive('events') && $query->query_vars['m']!='') { $query->set( 'post_type', 'events' ); $...


1

Personally, I would have just one (WordPress) cron event that fired daily. All queued emails are stored in a table/option. Now all you do in your cron handler is grab the next email in the queue, process it, and then delete it. There. One email a day. You could have the option in the UI that allows users to schedule emails to set a priority, so that it can ...


1

You should got a class for that button Try to find it and, if exists, you can fire event i.e using jQuery: jQuery(".button-class").click(...);


1

I don't think there is. You will have to use some local (browser-based) Javascript code to attach a function to the on-click event of the button. (Not a Javascript expert, but perhaps this will point you in a direction of investigation.)


1

You can simplify your save handler by checking if the POST variable is set. If it isn't, no need to handle the request: function save_files( $post_id, $post ) { if( ! isset( $_POST['image_upload_nonce'] ) || ! current_user_can( 'edit_post', $post_id ) ) return; // Good to go, handle everything. } For an explanation on why the save_post ...


1

I may be wrong but I don't think you can modify the Calendar Widget at least not that easy as like passing a post type and a field to query for. You have a few options: Create a Widget. Create a function like get_calendar() on line 1.406 on general-template.php file (wp 4) and pass it via get_calendar filter. Install a plugin that offers an event post ...


1

After pouring all of my points into this question and trying a few suggested options it seems that WordPress can't handle one minute crons. I have changed it to 5 minutes and haven't had any issues since. A few things that I tried over the course of weeks for testing purposes: Change the hook names to not include underscores [BUSTED] Rewrite the plugin. ...


1

your are comparing time against wrong time string: change: 'meta-value' => date('Y-m-d', strtotime('-6 hours')), //value of "order-date" to this 'value' => date('m-d-Y', strtotime('-6 hours')), //value of "order-date" because your time string is in m-d-Y format and you are check against Y-m-d which is wrong. NOTE if above trick doesn't work then ...


Only top voted, non community-wiki answers of a minimum length are eligible