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 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了