Skip to content

Instantly share code, notes, and snippets.

@iamcanadian1973
Last active January 4, 2018 02:43
Show Gist options
  • Select an option

  • Save iamcanadian1973/77c1ffb79fa6fca40e46b03d5f6afc76 to your computer and use it in GitHub Desktop.

Select an option

Save iamcanadian1973/77c1ffb79fa6fca40e46b03d5f6afc76 to your computer and use it in GitHub Desktop.
ARI INT
<?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