0

I need import css files from a folder in plugin directory to a plugin php file.

I tried

plugin_dir_path( __FILE__ );

<link rel="stylesheet" href="<?php echo __DIR__ . '/dahili/bootstrap.min.css'; ?>">
<link rel="stylesheet" href="./dahili/bootstrap.min.css">

but they gives wrong url.

for example, in my last trying, I get this adress:

http://www.hekim.deniz-tasarim.site/home/deniztas/hekim.deniz-tasarim.site/wp-content/plugins/my_post_plugin/widgets/dahili/bootstrap.min.css

but I need this:

hekim.deniz-tasarim.site/wp-content/plugins/my_post_plugin/widgets/dahili/bootstrap.min.css

how to get true address?

Note: Please dont close my question because of dublicate if you dont give 100% same question because I need real solution, I am not troll.

1

To solve this problem, we must use plugin_dir_url command.

For example:

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

?>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.