Plugins url issue

Function Reference – plugins url

Retrieves the absolute URL to the plugins or mu-plugins directory (without the trailing slash) or, when using the $path argument, to a specific file under that directory. You can either specify the $path argument as a hardcoded path relative to the plugins or mu-plugins directory, or conveniently pass __FILE__ as the second argument to make the $path relative to the parent directory of the current PHP script file.

 

Common Usage
The plugins_url() function is commonly used in a plugin file. Passing the __FILE__ PHP magic constant in the place of $plugin parameter makes the $path relative to the parent directory of that file:

 

 
Correctly:

<?php
echo '<img src="' . plugins_url( 'images/wordpress.png', __FILE__ ) . '" > ';
?>

 
Incorrectly:

<?php
echo '<img src="' . plugins_url( 'plugin-folder/images/wordpress.png') . '" > ';
?>

Leave a Reply

Your email address will not be published. Required fields are marked *