Make metabox of custom post type fully autosave- and bulk-/quick-edit compatible

WordPress does not send the content of custom fields during autosave (just title, slug and content). That’s why the custom field content will be deleted if you try to save the data: You cannot see the difference between deleted and missing content. I would create a separate autosave function for that, because the way WordPress … Read more

Custom post preview without saving

I found a nice way to do this using the preview_post_link filter, which allows you to rewrite the URL used by the preview operation. In my case I did something like: add_filter( ‘preview_post_link’, function ( $link ) { return ‘http://domain.com/mobile-preview/?src=”https://wordpress.stackexchange.com/questions/191918/. urlencode($link) .”%26admin_bar=false’; } ); When I click my preview button WordPress opens up my custom … Read more

Auto save permalink setting page with the plugin activation

You should use flush_rewrite_rules function for that. You have to remember, that this is expensive task, so you should not do it every time the site loads (many tutorials are making such mistake). Of course you can use it in your plugin activation hook: register_activation_hook( __FILE__, ‘myplugin_flush_rewrites’ ); function myplugin_flush_rewrites() { // call your rewrite … Read more

404 in gutenberg autosave of a Custom Post Type with custom rest_namespace

So, why the default namespace persist if I did all right? Would it be some javascript function of wordpress that would be doing the request on the incorrect route? What function? How to fix it? If the endpoint works then you changed it correctly, but if you’ve flushed rewrite rules/permalinks, and it still isn’t working, … Read more

Saving repeated option values in a custom query

If I understood you correctly, you’re basically asking how to group inputs by post ID? If this is the case, you could do something like this // group by input name=”renewal[<?php echo $post->ID; ?>]” // when saving $_POST[‘renewal’] // array of input values with each having post_id as key Or // group by post ID … Read more

Trigger Autosave or disable unsaved changes dialog

You could disable it with: source function disableAutoSave(){ wp_deregister_script(‘autosave’); } add_action( ‘wp_print_scripts’, ‘disableAutoSave’ ); Also not a real answer, edit the interval in the WP-config: http://codex.wordpress.org/Editing_wp-config.php#Modify_AutoSave_Interval The autosave function itself is in wp-includes/js/autosave(.dev).js