I have a php contact form that I use with all websites, so ideally I want to avoid using a plug in. The files used include:

• contact.php - A file with php/html write up which displays the form fields.

• contact-form.php - A file that contact.php connects to to send the information.

I've created the equivalent of contact.php as a static page in the Wordpress login.

The code within contact.php which connect to contact-form.php is as follows:

<form method="post" action="/contact-form.php" >

What I would like to know is how I would connect to this file in the instance of Wordpress - locating files in Wordpress is something which has always confused me...


1 Answer 1


You could put both the form and processing logic in the same file and submit the form to the same page by omitting the action attribute. Check $_POST vars to see if the form has been submitted and do your processing, otherwise display the form.

if( isset( $_POST['somevar'] ) ) :
    // process submission
else :
    // show form
  • I may be mistaken but I don't think static pages (in Wordpress login) accept php? Mar 1, 2013 at 15:23
  • you would create a page template specific to your page and add the code there, or create your own shortcode to add the form to a page.
    – Milo
    Mar 1, 2013 at 15:40
  • I'm sorry but I don't understand these options... I'm still pretty new to this so for me it's like a can of worms for a simple function. Mar 1, 2013 at 15:57
  • your theme renders each page with a template following the template hierarchy. when you're editing a page, you can select a custom template that will display that page on the front end. see the link above for info on creating that template, start with your theme's page.php template and duplicate then edit it.
    – Milo
    Mar 1, 2013 at 16:15
  • Ok I've done this, thanks. To do with the if statement above, how would I get this to work. I understand your logic but I can't seem to get it to work, whenever I click submit on the form for the data to be sent and validated it just returns the form... Mar 1, 2013 at 16:48

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.