WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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...


share|improve this question

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
share|improve this answer
I may be mistaken but I don't think static pages (in Wordpress login) accept php? – howardrocks Mar 1 '13 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 '13 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. – howardrocks Mar 1 '13 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 '13 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... – howardrocks Mar 1 '13 at 16:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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