Pass php variable via ajax (WordPress)

Question:

I am using ajax to upload some information to the page, the Ajax request uses a php file that has nothing to do with WordPress. Please tell me how I can make the functions located in the theme's function.php available for this file. Tried:

include('http://' . $_SERVER['SERVER_NAME'].'/wp-load.php');

Didn't help, tried

require_once('function.php')

Or maybe it is possible to pass the result of the function execution via GET?

Answer:

In your file, you need to connect the WordPress functionality, then the functions from functions.php will become available

require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
Scroll to Top