Plugin path comes wrongly
-
19-04-2021 - |
Domanda
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:
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.
Soluzione
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' );
?>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange