1) 编辑核心文件不是一个好主意您应该只处理/修改wp内容内或该文件夹下的文件
2) 与其调整核心小部件,不如根据自己的需要创建一个自定义小部件类。您只需构建自己的插件,它只使用轻量级设置。创建文件夹,进行插件的基本设置,
将其放在一个名为“stack overflow example widget.php”的文件中,将文件夹命名为相同的名称,然后tadaa。。这就是你的插件。CSS只需进入主题CSS,或稍后添加自定义样式表即可。我还没有测试过这段代码,但它应该可以正常工作。
<?php
/*
Plugin Name: Stack Overflow Example Widget
Plugin URI:  https://wordpress.stackexchange.com/questions/333724/making-the-default-latest-posts-wordpress-widget-show-thumbnails
Description: A widget to show the latest posts with a thumbnail.
Version:     1.0.0
Author:      user
Author URI:  https://www.example.com
License:     GPL2
License URI: https://www.example.com/imprint
Text Domain: yourtextdomain
Domain Path: /languages
*/
if(!defined(\'ABSPATH\')) {
    exit(\'NaNa nAnA NaNa nAnA NaNa nAnA Batman!\');
}
$dir = plugin_dir_path(__FILE__);
/* Init the plugin Textdomain, you have to google that, it\'s easy */
require $dir . \'textdomain.php\';
// Register the Widget in WordPress
function so_wp_register_widgets() {
    // Give it an ID
    register_widget(\'My_custom_widget\');
}
add_action(\'widgets_init\',\'so_wp_register_widgets\');
//Widget Class for all custom post type items
class My_custom_widget extends WP_Widget {
// Widget Construct
function __construct() {
    parent::__construct(
        \'so-example-widget\', // Id
        __(\'Custom Latest Posts\', \'yourtextdomain\'), // Name
        array(\'description\' => __( \'A widget to show the latest posts with a thumbnail.\', \'yourtextdomain\'))
    );
}
// Widget Init
function widget($args, $instance) {
    extract( $args );
    // these are the widget options
    $title = apply_filters(\'widget_title\', $instance[\'title\']);
    echo $before_widget;
    // Check if title is set
    if ( $title ) {
        echo $before_title . $title . $after_title;
    }
    $this->so_latest_posts_with_image(); // Call current Class, request Method
    echo $after_widget;
}
// Update Instance
function update($new_instance, $old_instance) {
    $instance = $old_instance;
    $instance[\'title\'] = strip_tags($new_instance[\'title\']);
    return $instance;
}   
// Widget Backend Form
function form($instance) {
    // Check values
    if( $instance) {
        $title = esc_attr($instance[\'title\']);
    } else {
        $title = \'\';
    } ?>
    <p>
        <label for="<?php echo $this->get_field_id(\'title\'); ?>">
        <?php _e(\'Title\', \'yourtextdomain\'); ?></label>
        <input class="widefat" id="<?php echo $this->get_field_id(\'title\'); ?>" name="<?php echo $this->get_field_name(\'title\'); ?>" type="text" value="<?php echo $title; ?>" />
    </p><?php
}
// HTML Widget Output
function so_latest_posts_with_image() {
    // Custom WP Query Arguments
    $custom_args = array(
        \'post_type\' => \'posts\',
        \'posts_per_page\' => \'96\',
        \'orderby\' => \'taxonomy, name\',
        \'order\' => \'ASC\'
    );
    $loop = new WP_Query( $custom_args );
    // Setup Layout und Loop
    $html = \'<div class="so-wp-widget-wrap">\';
        $html .= \'<ul class="so-wp-posts-all">\';
        while ( $loop->have_posts() ) : $loop->the_post();
            $html .= \'<li class="so-wp-posts-item">\';
                $html .= \'<a href="\'.get_the_permalink()\'" class="preview-image">\'.get_the_post_thumbnail().\'</a>\';
                $html .= \'<a href="\'.get_the_permalink().\'" class="so-wp-posts-permalink" title="\'.get_the_title().\'">\'.get_the_title().\'</a>\';
            $html .= \'</li>\';
        endwhile;
        $html .= \'</ul>\';
    $html .= \'</div>\';
    echo $html;
    wp_reset_postdata();
    }
}