Skip to main content
Share Your Experience: Take the 2024 Developer Survey
4 votes

WP Cron Doesn't Execute When Time Elapses

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 ...
sampi's user avatar
  • 159
3 votes

How to capture the selection:toggle event fired by wp.media

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 ...
Dave Romsey's user avatar
  • 17.7k
3 votes
Accepted

Pass argument to event hook

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" ...
Buttered_Toast's user avatar
3 votes
Accepted

Why is wp-cron only executing on page visit?

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 ...
Jacob Peattie's user avatar
3 votes

How to test wp_cron?

wp-cli is another way: Listing Events > wp cron event list +-------------------+---------------------+-----------------------+---------------+ | hook | next_run_gmt | ...
Ian Dunn's user avatar
  • 4,837
2 votes

Scheduled events disappear from events queue

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'); ...
Jamie Hamick's user avatar
2 votes

How to run a function every 5 minutes?

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 )...
Régis Ramillien's user avatar
2 votes

How to run a function every 5 minutes?

@johano's answer correctly explains how to set up a custom interval for WP cron job. The second question isn't answered though, which is how to run a cron every minute: In the file wp-config.php, add ...
Mike's user avatar
  • 576
2 votes

How to fire jQuery after $(window).on('load')

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, ...
WebElaine's user avatar
  • 9,430
2 votes
Accepted

How to write a plugin that "listens" every time, an edit occurs?

Use the "save_post" action hook, which is triggered every time a post or page is created or updated. In the function called by the hook, you can check the post content for new iframes, and ...
Nick Ennis's user avatar
1 vote
Accepted

How to compare Event period with Week period using get_posts(), meta_query, relation and compare

To be able to do this your post meta values need to be strings in a valid date format, e.g. 2022/01/31 for January 31st 2022. Note I used ISO standard timestamp format with the biggest value first, ...
Tom J Nowell's user avatar
  • 59.4k
1 vote
Accepted

Catching Gutenberg sidebar switch event

For everyone who is looking for a solution: The issue was that I wanted to use React. Component as I was sure it is required by WordPress. But Functional Component is also accepted, and in this case ...
mWin's user avatar
  • 71
1 vote

Event-Driven Pattern vs MVC?

I will try to explain it simplest as i can: MVC Framework - Is a framework, that uses MVC software architectural pattern. This pattern sepatares logic in Controller, data in Models, and HTML code in ...
PayteR's user avatar
  • 206
1 vote
Accepted

How to add onclick event to widget image

I would use the Google Tag Manager firing options: Or Old school jQuery solution: function($){ $('.widget_class').click(function() { ga('send', 'event', 'Sidebar Image', 'Promo ...
Drupalizeme's user avatar
  • 1,616
1 vote
Accepted

WordPress Scheduled Event Request Blocking

Yes, WP Cron won't run if nobody visits your site. You can also run into the PHP execution time limits There are ways to mitigate this however: Manually ping the cron URLs via a real cron job using ...
Tom J Nowell's user avatar
  • 59.4k
1 vote
Accepted

Manipulate post category after time

Your current function works pretty well, but it's hooked on to a post update hook so you need to actually edit/update a post for it to run. If you want the posts to be modified automatically after the ...
Cai's user avatar
  • 603
1 vote

Manipulate post category after time

The save_post hook passes the ID of the post to its callback function, so there's no need to use get_the_ID(). If you use wp_insert_post(), a new post will be inserted to database each time you save ...
Johansson's user avatar
  • 15.3k
1 vote

Sort custom post type by most current date picker

So thanks to Jacob Peattie and his helpful comments I was able to resolve this issue. meta_key was part of the group, but it wasnt prefixed by a group key. So, something like this totally works for ...
ivan marchenko's user avatar
1 vote

Trigger background job using AJAX

The way I do it, is to have three separate methods. One to start, one to stop, and one to do the process and check if it still should go. interface WPCronBackgroundProcessManagerInterface { /** ...
John Dee's user avatar
  • 503
1 vote

Trigger background job using AJAX

I don't think you need to worry about this running flag or unscheduling. Since you are scheduling a one-time job that will run immediately there's no reason to unschedule it. You just need to check ...
Fernando Claussen's user avatar
1 vote
Accepted

How to display upcoming events by dat with Modern Events Calendar Lite

i have found a solution, making a custom SQL query here is the code ( using WPML ) $startday = date("Y-m-d"); if ( defined( 'ICL_LANGUAGE_CODE' ) ) { $lang = ...
Gregory's user avatar
  • 582
1 vote
Accepted

Should i use a plugin for Event Manager or code my own needs?

It's a tough question that I think you will have to be the one to really answer, but hopefully I can provide some additional insight. Building events yourself means you will have exactly what you ...
MikeNGarrett's user avatar
  • 2,661
1 vote

How to select events within current week using wp_query

This is simple way provided by wordpress: $loop = new WP_Query( array( 'post_type' => 'custom_post_type', 'posts_per_page' => 7, 'meta_key' => 'meta_key', '...
Oussama Khoubrane's user avatar
1 vote
Accepted

How to select events within current week using wp_query

Changing the date format to Y-m-d on ACF and in my code was what fixed everything!
BudBroesky's user avatar
1 vote
Accepted

WP_Query meta_query results date by date

My idea is following. 1. Get the array of all meta dates your events have. DISTINCT in the MySQL query means do not include duplicates. <?php /* * From https://wordpress.stackexchange.com/a/9451/...
Max Yudin's user avatar
  • 6,307
1 vote
Accepted

Events Made Easy Plugin - Duplicate Title Tags

I try this following code with Events Made Easy version 2.0.35. It looks like you were near of the solution. you have found all bricks but you don't have succeed to assemble them. Try this code to ...
mmm's user avatar
  • 3,704
1 vote

Wordpress Media Uploader events

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(...);
Capolooper's user avatar
1 vote

Wordpress Media Uploader events

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 ...
Rick Hellewell's user avatar
1 vote

wp_schedule_event not working?

The ALTERNATE_WP_CRON basically does a transparent redirect on a user visiting your site and could result in a doing_wp_cron query parameter added to the URL. If for any reason your WordPress cron ...
contrid's user avatar
  • 111

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