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.

  • Any specific condition when you need to load wp-load.php file ?? – user3888958 Sep 21 '17 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 Sep 21 '17 at 5:27
  • Plugins are already part of a loaded WordPress, you shouldn’t need to call that file. – Jacob Peattie Sep 21 '17 at 5:27
  • Just use the AJAX API, no need for wp-load.php. – fuxia Sep 21 '17 at 5:29
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 .

  • 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 Sep 21 '17 at 13:03

Your Answer

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