Display Custom Post Type in Recent Posts

To display Custom Post Types in the regular Recent Post widget for sidebar(s),
we use following function which works flawless for us.
We use our own functions and try to prevent overhead often created by plugins.

Note: make a backup before adding this function into functions.php

/**
 * Display CPT on Recent Post widget
 *
 * @version WP 4.6.1
 */
add_filter( 'widget_posts_args', 'wpse241060_widget_recent_post_4_cpt' );
function wpse241060_widget_recent_post_4_cpt( $params )
{
    $params['post_type'] = array( 'post', 'cpt01', 'cpt02');
    return $params;
}

Read more in Codex

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)