我希望每3分钟自动更新/发布我正在编辑的一篇文章的更改。你知道我怎么能做到吗?
发布于 2022-05-31 04:24:12
Classic编辑器:
autosave.js文件
setInterval(function () {document.getElementById("publish").click()}, 300000);php函数
// Load js file on specific post type in class editor
function load_js_file_classic_editor( $hook ) {
global $post;
if ( $hook == 'post-new.php' || $hook == 'post.php' ) {
if ( 'post' === $post->post_type ) {
wp_enqueue_script( 'myautosave', get_stylesheet_directory_uri().'/includes/js/autosave.js' );
}
}
}
add_action( 'admin_enqueue_scripts', 'load_js_file_classic_editor', 10, 1 );古腾堡
setInterval(function() {
wp.data.dispatch( 'core/editor' ).savePost();
}, 60 * 1000); // 60 * 1000 milsechttps://wordpress.stackexchange.com/questions/406230
复制相似问题