Disable autosave for custom post type not working
-
Hi, I have created custom post type. And I have a problem without auto-drafts which are save always when I open an “add new form” or refresh it?
So I would like to disable autosave function only for my post type.My post type:
$args = array( 'labels' => $labels, 'public' => false, 'capability_type' => 'my_post_type', 'exclude_from_search' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_nav_menus' => false, 'show_in_menu' => true, 'show_in_admin_bar' => true, 'menu_position' => 5, 'hierarchical' => false, 'supports' => array( 'title', 'author' ), 'rewrite' => false, 'query_var' => false, 'has_archive' => false, 'register_meta_box_cb' => array( $this, 'remove_meta_boxes' ), ); register_post_type( 'my_post_type', $args );
I added an action in my construct method:
add_action( 'admin_print_scripts', array( $this, 'disable_autosave' ), 999 );
public function disable_autosave( ) { global $wp_scripts; print_R($wp_scripts); //there is autosave wp_deregister_script( 'autosave' ); print_R($wp_scripts); //there isn't }
wp_deregister_script function removed autosave form array, but the post was autosaved.
How can I do this?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Disable autosave for custom post type not working’ is closed to new replies.