I have two php files; one is called
page-my-template.php, and in it, I have a
<div></div> which I would like to contain all the code from another php file called
my-content.php. I thought this would be simple but it is proving to be a huge headache.
Before I continue, I am not using JSON, I am not using any forms or passing data, and I am not writing a plugin. I simply have a template file that only is used once on my page called
page-my-template.php, and I need to dynamically call the code from
my-content.php in a div. It seems natural to use
jQuery.load(), but no, please read below.
Inside the file
my-content.php, I am using many core functions such as get_option(), WP_Query(), etc. Of course these are causing 500 errors if I use
jQuery.load("my-content.php"). I realize I need to go through
admin-ajax.php in order to do this the proper way.
I've spent a lot of time reading tutorials about how to use ajax with Wordpress. All the tutorials I see on how to use ajax with Wordpress are very complicated and cover far more than what I am seeking, such as creating custom hooks, using forms, and writing plugins. Is there a simple way to include the functionality of
admin-ajax.php, so that I have access to the Wordpress core methods as I call the
my-content.php file? If so, please tell me what the code would be to include it, and exactly where to put that code.