ABSPATH only works when it's used by itself. For example:


will return:


which is along the lines of what i want.

But when i go

require_once(ABSPATH . 'wp-load.php');

it will return;


Which is not what i want.

I'm calling ABSPATH outside of the wordpress 'environment' with in part of a plugin.

  • I mean, if it's outside of the wordpress 'environment' it's not expected to work. Could you edit your question and add in more context of what you mean when you say it's both outside of WordPress yet inside a plugin? – Howdy_McGee Jun 1 '17 at 15:31
  • Well when i used ABSPATH by itself it works as it should, it gives the root of the site – Callum Jun 1 '17 at 15:32
  • @Callum why are you trying to load wp-load.php? Bootstrapping WordPress inside a standalone file in a theme or plugin can be fragile and dangerous, a security risk. Have you considered using a hook and exiting early for form handling/uploads/etc, or using a REST API for AJAX instead? – Tom J Nowell Jun 1 '17 at 15:49
  • @TomJNowell Is there any articles that show me how to do the methods you're mentioning? – Callum Jun 1 '17 at 15:57
  • @Callum there are thousands, but I trust you can google, I don't have a specific article to recommend to you. You could also ask how to create a shortcode or how to add an oembed provider on this site – Tom J Nowell Jun 1 '17 at 16:12

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.