如何将样式文件(如bootstrap)添加到菜单页面添加帖子?
我喜欢在添加帖子页面的元框中添加样式/// 图片在这里 in this page
这个鳕鱼解决了我的问题:)
function load_custom_wp_admin_style() {
wp_register_style( 'custom_wp_admin_css', editor_css_url . 'editor_boot_css.css', false, '1.0.0' );
wp_enqueue_style( 'custom_wp_admin_css' );
wp_register_style( 'custom_wp_admin_css_2', editor_css_url . 'editor_main_style.css', false, '1.0.0' );
wp_enqueue_style( 'custom_wp_admin_css_2' );
}
答案 0 :(得分:1)
function load_custom_wp_admin_style( $hook ) {
// Load only add post page and post edit page
if( $hook == 'post.php' || $hook == 'post-new.php' ) {
wp_enqueue_style( 'your-css-handler', get_template_directory_uri() . '/editor/css/my-style.css' );
}
}
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );
答案 1 :(得分:0)
试试这个:
add_action( 'admin_enqueue_scripts', 'admin_enqueue_scripts' );
admin_enqueue_scripts($hook) {
$theme_url = get_template_directory_uri();
wp_enqueue_style( 'bootstrap', $theme_url . '/css/bootstrap.min.css' );
}
答案 2 :(得分:0)
试试这个,
//Include CSS file for your plugin
function plugin_name_scripts() {
wp_enqueue_style( 'your-css-handler', plugin_dir_url( __FILE__ ) . 'editor/css/style.css' );
}
//enqueue the css file hook
add_action( 'wp_enqueue_scripts', 'plugin_name_scripts' );