Hot answers tagged

34

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'...


16

Firstly, define your custom cron job schedules. add_filter('cron_schedules', array($this, 'cron_schedules')); public function cron_schedules($schedules){ $prefix = 'cron_';// Avoid conflict with other crons. Example Reference: cron_30_mins $schedule_options = array( '30_mins' => array( 'display' => '30 Minutes', ...


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 ...


9

Finally have a chance to post my solution. Note that the events show All Day events first if there are any. Unfortunately I don't know a way around this as it is coded this way in a SQL query within one of the plugin files (and it is even commented in the file that All Day events are first). I am also using the event information collected into image data ...


8

First can you please confirm that you don't have any caching plugins enabled? Caching plugins can interfere with cron jobs because your visitors are not served a live page but a cached version of your page. If you have a caching plugin enabled, you can choose one of your pages, add an exclussion to your caching plugin's settings for that page so that it is ...


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

WordPress Cron allows you to schedule tasks, but they will only execute if there is a request made to the site. For each request that WordPress receives it will check to see if there are cron jobs to process, and if so fires off a request to /wp-cron.php?doing_wp_cron asynchronously to process the job. If a job's scheduled start passes without a request, ...


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

There aren't currently any shortcodes for venue information (address, postcode, other meta etc). However, you can copy the single-event.php template (find it in the templates directory of the plug-in) into your theme and edit it there to include venue information via provided template functions: Available functions When used inside the loop, you don't need ...


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

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

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 ...


2

I'll preface this by saying I have no experience with or knowledge of the plugin, this answer is based entirely on a 30 second scan of the code that registers the post type for use in the plugin, so you may uncover issues with this solution that my quick clicking of a test event didn't catch. With that said... The basic gist of this is to unset the post ...


2

Brady, I can't thank you enough for leading me to this solution. My client had already set all of the event dates without a custom field, and I wasn't about to go back and change everything. Your code initially threw an error when trying to post, but it worked with the following slight modifications (made to match the format used in wp-includes/post.php): ...


2

This one might do the trick for you... http://wordpress.org/extend/plugins/really-simple-events/ - low functionality but easy to install and make simple events. It seems only site admins can add events though.


2

Not sure if anyone else is dealing with this or if the answer in this post is outdated, but this is the method I used which was drastically less duplicated code: add_action('wp_feed_options', 'myaction_reverse_feed'); function myaction_reverse_feed(&$feed, $url=NULL){ if(!$url){ $url = $feed->feed_url; } if(!class_exists('...


2

You're enqueuing a specific version of jQuery. It's better to enqueue the version that comes with WP, like this: wp_enqueue_script('jquery'); in a function run by the hook wp_enqueue_scripts


2

I believe the meta_query part should be a nested array, so your query should be like this: $query = new WP_Query( 'post_type' => 'post', 'orderby' => 'meta_value', 'meta_key' => 'ENDS', 'order' => 'ASC', 'posts_per_page' => -1, 'meta_query' => array( array ( 'key' => 'ENDS', 'value'...


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

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 ...


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

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 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 ); ...


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

I think that you have poor data design. The solution, in my opinion, is to alter how your data is saved. If you saved all of your dates under the same key name you could run a relatively simple query to get the next date. $args = array( 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'event_dates', 'value' =...


1

Maybe try something along the lines of using pre_get_posts to edit the ordering. function reverse_order_homepage($query){ if($query->is_home()){ $query->set('order', 'DESC'); } return $query; } add_action('pre_get_posts', 'reverse_order_homepage');


1

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', '...


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