Skip to content

Instantly share code, notes, and snippets.

@danielbachhuber
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielbachhuber/062f822e605b6a688828 to your computer and use it in GitHub Desktop.
Save danielbachhuber/062f822e605b6a688828 to your computer and use it in GitHub Desktop.
<?php
/*
* Hack to restore the post_name that get_default_post_to_edit() noops
* Our assigned post_name via wp_insert_post_data can get fubar on post-new.php
*
* @see https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/post.php#L588
*/
add_filter( 'post_updated_messages', function( $messages ) {
global $pagenow, $post;
if ( 'post-new.php' == $pagenow && empty( $post->post_name ) ) {
$post = get_post( $post->ID );
}
return $messages;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment