I’m trying to submit a form to a php page that contains a WP_QUERY, I need the query to read it’s arguments from the submitted form using Ajax. When I load the page like this:
echo get_bloginfo('template_directory').'/mailform_action.php';
The WP_QUERY becomes undefined. And when I create a wordpress page and load that page as action=”test” such that page-test.php is the page name in the theme file I get an error form the console:
http://localhost/nafham_testing/testFailed to load resource: the server responded with a status of 404 (Not Found)
What’s wrong?
Try to include
wp_load.php
at the top of yourmailform_action.php
Use something like that at the top of your script :
<?php require('/the/path/to/your/wp-blog-header.php'); ?>