how to get wp-content folder in wordpress?

Viewed 28469

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 http://www.example.com/wp-content 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

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?

Related