If you need it on the first day of the month, you should still run this daily. Just be sure to check if “today” is the first of the month. Even your “first day of the year” would be executed if it is the first day of the month.
You can check this with the following:
$dtFirst = new DateTime('first day of this month');
$dtToday = new DateTime('today');
$interval = $dtToday->diff($dtFirst);
// format('%a') produces total 'days' from DateTime::diff()
if ($interval->format('%a') == '0'){
// Do your stuff here...
}
Doing this check daily will avoid issues with leap years, etc., without significant impact to your server.
I would also recommend you use a system cron to replace the WP Cron, to ensure you get a proper execution. WP Cron is too dependant on user activity.
Related Posts:
- Does wp-cron runs all tasks scheduled at same time together or one after other?
- How wp-cron can run in background if PHP is single threaded?
- Running WP Cron on multisite the right way
- Initialize WordPress environment to use in a real cron script
- Multiple wp_schedule_event cron jobs in plugin cause multi-execution
- How to use a frontend URL with a Plugin
- How to display a value from a radio button in the options menu in wordpress
- export a csv file from the database with a cronjob
- WP CRON duplicate wp_insert_post with has < and > tag
- WP Cron job timeout issues
- running wp-cron.php using php not wget
- Scheduling an event inside plugin class is not working
- Large WordPress CRON job
- Switch from wp-cron to a server cron job
- WordPress cron is running with previously set time intervals and not the updated one
- Can/should we delete wordpress cron jobs with no action?
- Setting up a cron job to auto update a custom field
- Drop down question
- How do I disable cache for a certain page?
- Problem with my Login Plugin
- How to return html as a string from php for WordPress
- post_exists stops working in a scheduled event
- CRON job to update wp_usermeta value each day or week based on server time
- Cron not sending wp-mail()
- Php cron job (wp-cron) not working
- How to execute add_action() function from custom plugin to Crontrol plugin or do_action()?
- Execute scheduled cron with ajax call to wp-cron.php
- Running WP-Cron on Multisite networks the right way?
- How can I cause run wp-cron to trigger sequentially?
- Action Hook Inside WordPress Plugin Shortcode
- How can I display Custom Post type Custom Columns and its Content in a Dashboard Widget?
- Calling function in loop causes repeat data
- Remove   from the_excerpt
- How do I access post_meta key with php?
- Find out last 7 days of upload images, last week uploaded image from Gallery and display them in different pages
- custom post type with role Vendor
- Separate array output into a
- How to override a plugins script
- Website completely messes up when logging out
- Need help removing […] after excerpt
- Calling PHP Titles inside Javascript Markup
- How can I use custom menus with a Bootstrap WordPress theme?
- Can I remove or edit an include() from a function with a filter?
- Remove in post content
- Call to undefined function error in plugin
- Initial offset of number of posts in home page on the posts page
- Adding Additional Variables on Menus Page
- Link to page with posts of specific type
- How do I make this Metabox show current DB value?
- Woocommerce custom Plugin in wordpress [closed]
- custom plugin with upload files does not work
- Function Display article [closed]
- Adding attribute to the post.php form tag in wp-admin
- Removed jQuery script from header.php , any problems?
- Using php inside javascript [closed]
- Execute Jquery when a specific page in my plugin is loading
- How can I get plugin meta data without knowing the plugin folder?
- Using flickr api in custom wordpress plugin
- Toolbar Hidden in a Virtual Page
- PHP: How to access db the right way in plugin?
- What is the difference between Null vs Empty (Zero Length) string?
- select a single val though a table in wordpress
- Replacing WordPress Icons (menu,icons32, etc)?
- WordPressUser Submission Form
- calling admin-ajax.php from admin-ajax.php
- Submit form to db
- Shortcode displaying at the top of the page [duplicate]
- Get category id when SEO URL is turned on
- Is it possible to isolate and use WordPress functions outside of wordpress
- WordPress custom post type and taxonomy
- How to get the second slug of a page url?
- Custom forms with HTML
- Wrap title and excerpt in a div (latest posts block)
- Search AJAX Filters – Multiple Query Loops Into One Loop (Optimization)
- PHP: $_SESSION destroyed after page reload for my custom session
- Displaying images outside the content
- send popup after wp_redirect()
- WordPress – Get Posts with Category data
- no_rest_route error on custom routes
- Add a custom WooCommerce settings tab with sections
- Flatten Responses returned via WP REST API via WP_Error for obfuscation
- custom add note meta box with add button in wordpress
- WordPress cron job running more than once
- How to use wp_send_json() and output the value with ajax?
- How does add_option() function enable action hooks to fire right after actiavtion?
- Unzip file in functions.php, and add it to cron
- Time Delay a URL Redirect for Specific Page
- How to correctly escape an echo
- PHP using external anonymous function inside class
- how to changes mobile menu toggle breakpoint in WordPress
- Cascading dropdown select search based on Parent Page & Child Page
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Display WordPress search results based on the selected Sub-Category
- PHP inside echo HTML
- html form: redirect page after form completes submit function and posts data
- Ajax on the Administration Side of plugin – wp_localize_script – how to pass value from JQuery to PHP function in class?
- Problem with inserting multiple images in gallery of each WooCommerce product programmatically
- Is it possible to access admin-ajax.php using PHP?
- i need to make custom cron_schedule with custom interval time as a parameter into a custom payment gateway plugin wordpress
- Payment field disappears on custom Paypal plugin