您需要加载一些wp管理样式。
因为我找不到任何方法让wp\\u enqueue\\u style()接受url参数,所以我在这里通过wp\\u head hook函数加载样式。
add_action( \'wp_head\', \'load_admin_media_styles\', 10);
function load_admin_media_styles(){
// list all style libs the post page of wp-admin loaded, but we may only need to load 2 of them
$ary_libs = array(
\'common\',\'forms\',
// \'dashicons\', \'admin-bar\',\'buttons\',\'media-views\',
// \'admin-menu\',\'dashboard\',\'list-tables\',\'edit\',\'revisions\',\'media\',\'themes\',\'about\',\'nav-menu\',
// \'s\',\'wp-pointer\',\'widgets\',\'site-icon\',\'l10n\',\'wp-auth-check\',\'wp-color-picker\'
);
$admin_media_styles_url = add_query_arg(
array(
\'c\' => 0,
\'dir\' => \'ltr\',
\'load[]\' => implode(\',\', $ary_libs),
\'ver\' => \'you_wp_version\'
),
admin_url().\'load-styles.php\'
);
echo "<link rel=\'stylesheet\' id=\'admin_styles_for_media-css\' href=\'".$admin_media_styles_url."\' type=\'text/css\' media=\'all\' />";
}
我在我的localhost中进行了尝试,效果很好,希望这对您有所帮助。