Last active
January 4, 2018 02:43
-
-
Save iamcanadian1973/77c1ffb79fa6fca40e46b03d5f6afc76 to your computer and use it in GitHub Desktop.
ARI INT
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
| <?php | |
| /** | |
| * Checks if the the post has excerpt or not | |
| * Code reference: https://wordpress.stackexchange.com/a/52897/12615 | |
| */ | |
| // | |
| function wpse_40574_populate_excerpt( $data, $postarr ) | |
| { | |
| if( ! isset( $data['news'] ) ) { | |
| return; | |
| } | |
| global $wpse_40574_custom_excerpt_length; | |
| // check if it's a valid call | |
| if ( !in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) && 'post' == $data['news'] ) | |
| { | |
| // if the except is empty, call the excerpt creation function | |
| if ( strlen($data['post_excerpt']) == 0 ) | |
| $data['post_excerpt'] = wpse_40574_create_excerpt( $data['post_content'], $wpse_40574_custom_excerpt_length ); | |
| } | |
| return $data; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment