I have my custome theme in wordpress.This is the path of my custome theme. C:\wamp\www\wordpress2\wp-content\themes\sscy1002\sscy1002

I have created a Page in wordpress which contains some form elements. Here is my Page Code :

 <form action="<?php bloginfo('stylesheet_directory'); ?>/Query.php" enctype="multipart/form-data" method="post" name="contact">
<label for="author">Name:</label> <input class="required input_field" id="author" type="text" name="author" />
    <div class="cleaner h10"></div>
    <label for="email">Email:</label> <input class="validate-email required input_field" id="email" type="text" name="email" />
    <div class="cleaner h10"></div>
    <label for="subject">Subject:</label> <input class="input_field" id="subject" type="text" name="subject" />
    <div class="cleaner h10"></div>
    <label for="text">Message:</label> <textarea class="required" id="text" cols="0" name="text" rows="0"></textarea>
    <div class="cleaner h10"></div>
    <label for="image">Image:</label><input type="file" name="file" />

    <input class="submit_btn float_l" id="submit" type="submit" name="submit" value="Send" />
    <input class="submit_btn float_r" id="reset" type="reset" name="reset" value="Reset" />


And here is my Query.php code under C:\wamp\www\wordpress2\wp-content\themes\sscy1002\sscy1002 directory :


echo $name."<br/>";
echo $email."<br/>";
echo $subject."<br/>";
echo $message."<br/>";
echo "<img src='imagess/".$image."' alt='image'>";

But when I am submitting form I am getting fatal error :

Fatal error: Call to undefined function get_header() in C:\wamp\www\wordpress2\wp-content\themes\sscy1002\sscy1002\Query.php on line 2

Please help me how to pass transfer data from one page to another file(or if Page) in wordpress. I also searched answer on google but and tried all the way which I got from google but not working.

Sorry about wrong formatting of Question. Please help me!!!! Thanks!!!

  • 3
    Create Query.php as page template and add it to page then pass url of this page in form action attribute.codex.wordpress.org/Theme_Development#Custom_Page_Templates Apr 12, 2013 at 4:23
  • There's no need to create a non-standard WP template file for this. Why not just place your form functionality into functions.php where it should be? tommcfarlin.com/sending-data-post
    – sagalbot
    Feb 19, 2014 at 23:33
  • Have a look here: wordpress.stackexchange.com/questions/201940/… You would need to save data that u need in session or cookie and then on the second page u could use them...
    – Maikal
    Jun 14, 2016 at 1:49
  • But if u don't understend what is the problem: Problem is in that u'r loading custom php file wich is not connected to wordpress php files, so you don't have get_header, add_action atc. functions avilable. If u want to make a page witch will take your post data you should consider creating page template and submiting form to a page link wich has page template...
    – Maikal
    Jun 14, 2016 at 1:53

4 Answers 4


You can try to use functions.php to handle the form submission and send the data via AJAX.

Add a hidden field in your form with the action to be taken (on functions.php):

<input type="hidden" name="action" value="save_contact"/>

In you footer.php add the jQuery code to handle the AJAX request:

function ajaxSubmit(e){
var formData = jQuery(this).serialize()

    url: "<?php bloginfo('url'); ?>/wp-admin/admin-ajax.php",
        data: formData,
        success: function(response){
    error: function(error){
return false;

Finally, In you functions.php file:

add_action('wp_ajax_save_contact', 'save_contact');
add_action('wp_ajax_nopriv_save_contact', 'save_contact');
function save_contact(){
     //Do whatever you want here...

Hope it helps! :)


add following code before get_header()


you getting error because your file is not for a page created with wordpress its just a php file, you need to include load.php file to load all the required functions.


You should use http://example.com/page-slug/

where page-slug is page created by make Query.php as template.

<form action="http://example.com/page-slug/" enctype="multipart/form-data" method="post" name="contact">

Please replace form action path from <?php bloginfo('stylesheet_directory'); ?> to <?php bloginfo('template_directory'); ?>

Then check it..

  • 1
    Please explain, how that would prevent the Call to undefined function error, the OP is getting. Jul 17, 2013 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.