Created
June 21, 2020 13:57
-
-
Save izzygld/055b6ccdb3301b553ad0973dc1004071 to your computer and use it in GitHub Desktop.
Now pending posts get displayed to anyone and private posts are still only visible to admins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* How to make draft posts or posts in review accessible via full url / slug. | |
* Source: - https://wordpress.stackexchange.com/questions/218168/how-to-make-draft-posts-or-posts-in-review-accessible-via-full-url-slug | |
*/ | |
function auto_save_post_status( $post_id, $post, $update ) { | |
if( $post->post_status == "draft" && ! $post->post_name ) { | |
remove_action( 'save_post', 'auto_save_post_status', 20, 3 ); | |
wp_update_post( array( 'ID' => $post_id, 'post_status' => 'publish' ) ); | |
wp_update_post( array( 'ID' => $post_id, 'post_status' => 'draft' ) ); | |
add_action( 'save_post', 'auto_set_post_status', 20, 3 ); | |
} | |
} | |
add_action('save_post', 'auto_save_post_status', 20, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment