dtp0760 2019-05-01 03:30
浏览 245

我无法在我的wordpress网站的插件中加载自定义样式

I am trying to call my custom styles in my wordpress plugin. I tried the wp_enqueue methods but i could not find my style sheet getting loaded.

I have tried examples from stackoverflow itself but it is not working for me. I checked the enqued styles using debug bar - dependancy tool and cannot find the styles in that too. Please check the link for my enqued styles . debug bar The following are the two different ways, i tried to load my css.

function wp_adding_styles1()
{
wp_enqueue_style('my_eastern_charts_stylesheet', plugin_dir_url(__FILE__) . 'eastern_charts_stylesheet.css');   

}
add_action('wp_enqueue_scripts', 'wp_adding_styles1');

function wpb_adding_styles() {
wp_register_style('my_stylesheet', plugins_url('eastern_charts_stylesheet.css', __FILE__));
wp_enqueue_style('my_stylesheet');
}
add_action( 'wp_enqueue_scripts', 'wpb_adding_styles' );

Directory Structure

  • 写回答

2条回答

  • dongying6896 2019-05-25 11:10
    关注

    Try This

    function custom_load_plugin_css() {
       $plugin_url = plugin_dir_url( __FILE__ );
    
            wp_enqueue_style( 'style1', $plugin_url . 'css/style1.css' );
            wp_enqueue_style( 'style2', $plugin_url . 'css/style2.css' );
        }
        add_action( 'wp_enqueue_scripts', 'custom_load_plugin_css' );
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算