Created
January 9, 2018 15:47
-
-
Save MWDelaney/fd0bed89b891e3ff0850428703786397 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
/** | |
* Set excerpt from ACF field | |
*/ | |
add_action('acf/save_post', function($post_id) { | |
$post_excerpt = get_field( 'short_description', $post_id ); | |
if ( ( !empty( $post_id ) ) AND ( $post_excerpt ) ) { | |
// Update post options array | |
$update_post_excerpt_args = array( | |
'ID' => $post_id, | |
'post_excerpt' => $post_excerpt, | |
); | |
wp_update_post( $update_post_excerpt_args ); | |
} | |
}, 50); |
Git perfect!
Solved 3 days of failed attempts.
Big thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you, this has been quite useful to me !
And I shared it here : https://wordpress.stackexchange.com/questions/124422/mandatory-excerpt-for-custom-post-type