I am in a hypothetical plugins root folder. Now I want the path of the wp-content directory.

I need its path in some functions. Please guide me.

I tried this, but this doesn't seems to work:

$plugin_dir = ABSPATH . 'wp-content';

enter image description here

  • wp-content might not even exist. You can customize every child directory and set it to some custom path. The real question here is why you want that directory. :) – fuxia Jan 1 at 21:44
  • Please explain that under what scenario this may be true "might not even exist"? wp-content, wp-admin, wp-includes → I think these are definite directories? – The WP Intermediate Jan 1 at 21:47
  • You can give every subdirectory a separate path outside of the WP installation, and then just set wp-content to be equal with the installation root. Still, why do you need that path? – fuxia Jan 2 at 1:09
  • Hi there @fuxia, Thank you so much I was not aware of that, but I think that this is a high-level thing. Organizations that are handling huge websites, in order to increase website security they change those directory paths. – The WP Intermediate Jan 2 at 12:44
  • 1
    Okay. If it is only for your own sites, you can go with that. :) The constant WP_CONTENT_DIR should give you what you need. – fuxia Jan 2 at 12:54

Your Answer

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

Browse other questions tagged or ask your own question.