snippets

Difference Between plugin_dir_url vs plugins_url

Difference Between plugin_dir_url vs plugins_url

Function plugin_dir_url() This will return URL of the plugin directory with a trailing slash at the end. So this can be easily used to link to the plugin directory. Example #1: [php] plugin_dir_url( __FILE__ ); // Return - http://www.example.com/wp-content/plugins/plugin_name/ [/php] Example #2: [php] include plugin_dir_url( __FILE__ ) . 'assets/images/zytheme-logo.png'; // retrun http://www.example.com/wp-content/plugins/plugin_name/assets/images/zytheme-logo.png [/php] Example #3: [php] define('PLUGIN_URL', plugin_dir_url(__FILE__)); echo PLUGIN_URL