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.
1 Answer
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.– MiloCommented Sep 21, 2017 at 13:03
-
This would also break on something like roots/bedrock. Commented Jul 31, 2021 at 12:02
wp-load.php
.