How to check for duplicate record before saving a Custom Post Type

See this answer for solution, see comments there about error messages. That should work with Classic editor. It could work with Gutenberg too, but it would need additional effort to get correct error messages. UPDATE: If using classic editor and preventing publishing of invalid records is enough, you can use this code: function my_save_post($post_id) { … Read more

Custom post edit with button to save post and start creating new

I know this is kinda stupid solution, but 2s timeout is acceptable solution add_meta_box(“addanotheritem”, ‘Add another’, ‘addanother_metabox’, ‘custompost’, ‘side’, ‘high’); function addanother_metabox() { ?> <script type=”text/javascript”> function saveAndGo() { jQuery(‘button.editor-post-publish-button__button’).click(); setTimeout(function() { window.location=’./post-new.php?post_type=custompost’; }, 2000); return false; } </script> <button onclick=’javascript:saveAndGo();’>save & add another</button> <?php }

Disable autosave with `function.php` for custom post wordpress?

There are a few methods to disable autosave/revisions. Disabling autosave: Using action and dequeuing the .js that is responsible for autosave, this goes into functions.php, located in the current theme directory. function bt_disable_autosave () { wp_deregister_script(‘autosave’); } add_action(‘admin_init’, ‘bt_disable_autosave’); Using a constant to set the interval so high (one day) it will never happen unless … Read more