I have created a file for ajax in
theme/mytheme/ajax-form.php and there was an error while using this code:
$db_result = $wpdb->get_results( 'select * from batch_number' );
get_resultis not a function
Then I've included
wp-load.php at the top, so the issue was fixed and I got the result, but now the issue is: I'm hard coding the path of
wp-config.php file. Instead, can we take the root path of my project?
I've tried many things, but no luck. I've tried this:
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wptheme/wp-load.php' );
wptheme is my project's root folder and I don't want to hardcode it like that.