I’m sorry, I converse a bit English.
My customized theme:
~/wp-content/themes/mycustomtheme/capabilities.php
perform mct_task() {
embrace( get_template_directory() . '/inc/cron.php' );
}
add_action( 'mct_hook', 'mct_task' );
//
perform mytheme_setup_options() {
if( ! wp_next_scheduled( 'mct_hook' ) ) {
wp_schedule_event( time(), 'hourly', 'mct_hook' );
} else {}
}
add_action( 'after_switch_theme', 'mytheme_setup_options' );
~/wp-content/themes/mycustomtheme/inc/cron.php
$category_id = wp_create_category( 'Tremendous' );
// $my_post = array( 'post_category'=> array( $category_id ) );
wp_insert_post( $my_post );
~/error_log
PHP Deadly error: Uncaught Error: Name to undefined perform wp_create_category() in...
Why? What’s the downside?
I would love use class at wp_insert_post with wp-cron. If the class exists, use the class ID, if not exists, create new class.