For running in WP cron, you’ll define your function, and then hook the function to the cron’s name.
Example:
function cron_function() {
...
}
add_action( 'cron_hook', 'cron_function' );
if ( ! wp_next_scheduled( 'cron_hook' ) ) {
wp_schedule_event( time(), 'one_minute', 'cron_hook' );
}
See WordPress developer resource for more info:
https://developer.wordpress.org/plugins/cron/scheduling-wp-cron-events/
Related Posts:
- Is it mandatory to use $wpdb->prefix in custom tables
- WordPress and multithreading
- Actions or filters fired when data is saved in a custom table
- Custom Plugin Database relations
- Activation hook not creating table
- How to create database table, add data, update and delete using wpdb via plugins?
- Using WPDB to output raw XML fails because of wp-blog-header.php
- wpdb->prepare and mysql UPDATE – how is it done?
- $wpdb->update Issue
- WordPress database error: [Query was empty] – using $wpdb->prepare()
- How to get inserted row IDs for bulk/batch insert with wpdb query?
- Update database record in plugin
- WordPress plugin tables become corrupt
- Post meta vs separate database tables
- Default table collation on plugin activation?
- Using a database view = evil incarnate?
- Check for success of $wpdb->update() correctly
- Getting wrong relationship value in $args in wp_Query?
- What is the added “complexity” of custom tables?
- How is the data stored in the database?
- How to modify post content before writing to database?
- $wpdb->insert is changing a value
- Retrieving custom fields with $wpdb->get_results
- Sample — test — data for large WordPress install
- Is there any reason only 1 (my) IP would be added to this table using $wpdn->insert?
- why creating tables using $wpdb is not being executed while installing plugins?
- How to use mysql IN statement with wpdb update method?
- How to store data for posts/pages built with drag-n-drop builder?
- What for the tables ending with the meta used in database of wordpress?
- Creating table with plugin is not working
- dbDelta() Error – Incorrect index name ” for query ALTER TABLE
- Update/insert only a column of database table
- How to Create database table when Plugin installed/activated, and delete database when Plugin deleted
- Where to store the name of a custom table?
- include wp-blog-header not working on MAMP
- I’m designing a plugin to create database indexes. Suggestions?
- WordPress database error for query INSERT INTO
- How to connect to AWS RDS external database (not for the core WordPress db)
- SQL query for custom taxonomy slugs
- Issue regarding $wpdb->prepare()
- Error on inserting a form value to database
- Are there any scripts, classes, and/or functions built-in to WP for a plugin to export/import its saved data from wp_options?
- Strange issue saving custom field data for a WooCommerce order
- how to search users by ajax live search
- Form doesnt save to database
- Adding custom end points, No error line
- Intermittent database errors when accessing WordPress database
- Updating Woocommerce Settings API when WordPress Settings API saved and vise versa
- Update results, Before deleting the related category [closed]
- Storing data in wordpress database from ajax call from different website
- Is using custom table to suit business needs instead of transients a big hit to page load speed?
- Plugin Development for registered users
- Optimising a big WordPress site
- dbDelta SQL Query Not Working
- What is the best way to store a few fields?
- Delete data from database using row action
- Show dynamic list of products from custom api of another database under same host
- How do I have now a duplicated user entry if this is not allowed (and I cannot replicate it)?
- Issue running db create table query from static method
- Alternative functions for mysql_free_result and mysql_ping in wordpress functions
- Make Database query only when option is updated
- Can we intercept user_login and user_pass from a wp_login_form?
- How best to handle database version dependence (from $wp_db_version)
- WP: Search and replace in DB programmatically
- Two different wordpress sites – same server and IP address. Gaining Access to database 1 of 2
- Plugin Development: Storing and Manipulating Data That Fits JSON in Database
- Data inserted by wpdb insert is different than data pressnt in database.
- How to avoid conflicts with db.php / $wpdb and other plugins that decide to use them?
- How do I debug an error that a plugin is causing?
- $wpdb in php 5.5
- Update plugin settings option_name for big plugin update
- select a single val though a table in wordpress
- Plugin to create Posts and Forums then choose category and parent forum
- Why doesn’t my Table get created?
- How to display specific data from a custom table to logged in users with a custom role
- $wpbd->insert_id is returning null
- Error code when migrate
- How to securely controlling data without keeping it in postmeta?
- WordPress how do I echo SUM from a column of a MySQL table by user id AND type_operation
- WordPress Query doesn’t return the correct value
- Use admin-post to submit form data to external database
- Save in my custom admin page and redirect to the saved object
- Relational / Associate tables using native WordPress functionality
- How to store in the database directly the translation?
- How and when would I implement some code which would take data from one part of the Db and put it in another?
- How to implement pagination into a wpdb->result query?
- How to CRUD from wordpress database in wordpress theme?
- Ajax not working to insert, query and result data
- Why Worpdress doesn’t create table in database?
- Form and database, plugin development
- Associating special meaning with user id 0
- What method should I use to store my plugin data (multi level menus with options on each item)
- How to add additional field in a table row after creating a table?
- Nothing happens on WordPress Update command
- Fixing plugin for wpdb::prepare
- Running one-off cron jobs when WP_DISABLE_CRON is true: can I hit /wp-cron.php?
- How to create a database table in WordPress using PHP
- Can I log the searches that are returning 404 in the DB?
- Programmatically creating posts based on external JSON feed (asynchronously)
- Making a user platform reachable by a qr code on a pin-back-button [closed]