admin管理员组

文章数量:1122846

I looked at this question:

plugin css is not being applied to the page?

but I couldnt solve my problem.

I use below code like the question:

 <?php
                    function libload()
                    {
                    wp_register_style( 'foo-styles',  plugin_dir_url( __FILE__ ) . 'dahili/bootstrap.min.css' );
                    wp_enqueue_style( 'foo-styles' );

                    wp_register_style( 'foo-styles2',  plugin_dir_url( __FILE__ ) . 'dahili/style.css' );
                    wp_enqueue_style( 'foo-styles2' );

                    wp_register_style( 'foo-styles3',  plugin_dir_url( __FILE__ ) . 'dahili/responsive.css' );
                    wp_enqueue_style( 'foo-styles3' );

                    }
                    add_action('wp_enqueue_scripts','libload');
                  ?>

style files are loading as you can see below link but wp not apply them:

/sample-page/

How can I solve this problem?

I looked at this question:

plugin css is not being applied to the page?

but I couldnt solve my problem.

I use below code like the question:

 <?php
                    function libload()
                    {
                    wp_register_style( 'foo-styles',  plugin_dir_url( __FILE__ ) . 'dahili/bootstrap.min.css' );
                    wp_enqueue_style( 'foo-styles' );

                    wp_register_style( 'foo-styles2',  plugin_dir_url( __FILE__ ) . 'dahili/style.css' );
                    wp_enqueue_style( 'foo-styles2' );

                    wp_register_style( 'foo-styles3',  plugin_dir_url( __FILE__ ) . 'dahili/responsive.css' );
                    wp_enqueue_style( 'foo-styles3' );

                    }
                    add_action('wp_enqueue_scripts','libload');
                  ?>

style files are loading as you can see below link but wp not apply them:

http://www.hekim.deniz-tasarim.site/sample-page/

How can I solve this problem?

Share Improve this question asked Apr 13, 2020 at 18:27 Faruk rızaFaruk rıza 982 silver badges11 bronze badges 2
  • 1 No, the style files are not loading. If you view your source, those files aren't listed. What file is your code running in? Is the plugin active? – WebElaine Commented Apr 13, 2020 at 18:38
  • @WebElaine yes, plugin is active.I need all css files – Faruk rıza Commented Apr 13, 2020 at 18:41
Add a comment  | 

3 Answers 3

Reset to default 1

Change integratation code with this:

  <?php
                    wp_register_style( 'foo-styles',  plugin_dir_url( __FILE__ ) . 'dahili/bootstrap.min.css' );
                    wp_enqueue_style( 'foo-styles' );

                    wp_register_style( 'foo-styles2',  plugin_dir_url( __FILE__ ) . 'dahili/style.css' );
                    wp_enqueue_style( 'foo-styles2' );

                    wp_register_style( 'foo-styles3',  plugin_dir_url( __FILE__ ) . 'dahili/responsive.css' );
                    wp_enqueue_style( 'foo-styles3' );
                  ?>

Your code looks correct, but the page you linked to doesn't seem to have them included.

This means that this line is not being run:

add_action('wp_enqueue_scripts','libload');

Check if the php file that you have it inside of is included by one of your plugin files?

Or that you are trying to include a file with the wrong path.

Check that the file is in a plugin not a theme folder, or you will need a different path.

I ran into the same problem and there was a naming conflict in a different plugin with the alias in the first argument in wp_enqueue_style(); Wordpress should really have some error handling for this. I went a month until I realized that could be the problem. look into this bit of documentation here

本文标签: wp enqueue scriptplugin css is not being applied to the page