0

I need to call wp-load.php in my plugins file but in case if I call it directly the plugin is not being accepted for wordpress repository and we are been given issue. So please guide me how can we include the "wp-load.php" file in wordpress.

4
  • Any specific condition when you need to load wp-load.php file ?? Commented Sep 21, 2017 at 5:22
  • Yes I am calling a ajax file where I need to enter data in db table here I need to call wp-load.php file in that case
    – user111017
    Commented Sep 21, 2017 at 5:27
  • Plugins are already part of a loaded WordPress, you shouldn’t need to call that file. Commented Sep 21, 2017 at 5:27
  • Just use the AJAX API, no need for wp-load.php.
    – fuxia
    Commented Sep 21, 2017 at 5:29

1 Answer 1

1

To call wp-load.php outside wordpress, for example in your case to do some quick ajax stuff, add the following code on the top of your php file.

<?php include($_SERVER['DOCUMENT_ROOT'].'/wp-load.php');?>

But as @fuxia said is better to use the WP AJAX API especially if you create a plugin .

2
  • As op states in their question, your plugin will be rejected from official repository if you do this, so it's not really a solution.
    – Milo
    Commented Sep 21, 2017 at 13:03
  • This would also break on something like roots/bedrock. Commented Jul 31, 2021 at 12:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.