iamcanadian1973
1/4/2018 - 12:47 AM

ARI INT

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;
}