Wordpress Technology

Wordpress Tips, Tutorials, Hacks

Plugin Directory and URL in WordPress

Wordpress: Find Plugin Directory

Wordpress: Find Plugin Directory

Using PHP functions to find the directory and url of current script might give you wrong result. However, there is a better way in WordPress to find plugin directory and URL.


$url = get_bloginfo('url')."/wp-content/plugins/plugin-name/images/hello.jpg";
$directory = dirname(__FILE__)."/plugin-name/images/hello.jpg";

dirname(__FILE__) might give you uncorrect result.

In WordPress,

$url = WP_PLUGIN_URL."/plugin-name/images/hello.jpg";
$directory = WP_PLUGIN_DIR."/plugin-name/images/hello.jpg";

Hope, it helps!

Both comments and pings are currently closed.

© 2009 | Made by Vancouver Web Design | Internet Marketing