Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Chris Hubbard](https://uploads.teamtreehouse.com/production/profile-photos/104139/micro_MarketHubb-Logo-2.png)
Chris Hubbard
2,253 PointsDifference between WP_PLUGIN_URL & plugins_url
Can someone help me understand why WP_PLUGIN_URL
was used when linking to images, but plugins_url
was used when loading the styles?
Aren't they both returning a path to our plugins directory? Are there situations when one should be used over the other?
1 Answer
![Kevin Korte](https://uploads.teamtreehouse.com/production/profile-photos/86647/micro_me.jpg)
Kevin Korte
28,148 PointsThat's a good question. WP Codex says the WP_PLUGIN_URL
is a constant used by plugins_url
to find the correct path, but should not be used directly in plugins or themes.
http://codex.wordpress.org/Determining_Plugin_and_Content_Directories
And for the Codex for plugins_url
in the notes section, it says it uses WP_PLUGIN_URL
[edit] constant internally, to compose the resultant URL. Note that direct usage of WordPress internal constants is not recommended.
http://codex.wordpress.org/Function_Reference/plugins_url
Maybe things have changed since these lessons were made? I'm just starting to get into plugin writing after becoming comfortable with theme development, so I too am curious as to why this is, just so we understand how to make our own good decisions later on projects.