How to Get Wp-Content Folder in Wordpress?

if my main.php file is located inside /wp-content/plugins/myplugin/folder/folder/folder/ why including urls.php , located inside /wp-content/uploads/folder/ doesn't work with this path:

include_once("../../../../../uploads/folder/urls.php");

it works only if placed inside same folder as main.php with path ('urls.php');

2 Answers

you can use content_url() it's located with wp-content folder.

Or for path

you can use WP_CONTENT_DIR it'll located to wp-content folder.

require_once(WP_CONTENT_DIR. 'uploads/folder/urls.php');

Check more info Documentation

4

It seems strange. Do you have any error message when you run your main.php? Try to check again, maybe a typo somewhere. Do you take help of Text editor auto-completion when calling urls.php?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest