I have a contact form previously used in static websites that I’d like to adapt to use in WordPress. I realize there are numerous plug-ins such as Contact Form 7, but would rather use this since it’s simple and I’m familiar with it. Basically, on submission the form page goes to a second PHP page for the post action, rendering a confirmation note with all of the entered data while simultaneously sending an HTML email using the same data.

The flat HTML structure is:

examplesite.com/contact/page-contact.php = Form Page

examplesite.com/contact/confirmation/page-form-mail.php = Output Page

This has worked fine for my non-CMS purposes. To adapt to WordPress, I set both up as Pages, and included all the form PHP in their respective page templates. Hence:

wpsite.com/contact – “Contact” page template = “page-contact.php”

wpsite.com/contact/confirmation – “Confirmation” page template = “page-form-mail.php”

My problem is in referencing the confirmation page file in the contact form’s action so the confirmation page actually works within WordPress.

When the confirmation page URL is loaded independently, the output skeleton (without the data) is displayed correctly within WordPress. But hard-coding the actual directory path or using other WP method to generate same (i.e., action=“http://wpsite.com/contact/confirmation/” ) produces blank output – I assume because PHP is referencing the directory and not the template file, even though the confirmation page is set up using the template.

Alternatively, the confirmation output page can instead be referenced directly via:

action="<?php bloginfo('stylesheet_directory'); ?>/page-form-mail.php"

This is functional (it outputs and emails the data) but is no longer within WordPress and of course exposes the full template URL path:


Seems I’m missing something pretty basic here. How do I reference the actual confirmation php file in the form action and still keep it within WP?

Thanks for any suggestions!

Note: initially I was using “name” as one of the form variables until I realized that was one of WP’s internals, so then I custom-prefixed all my variables but it’s still not working. (In reading other form questions here, that seems to be a common problem!)

  • I know ut's been a while but i'm also struggling with this. What was the solution you found in the end?
    – kevin
    Sep 16, 2014 at 15:08

1 Answer 1


I would like to recommend you to read The Rewrite API: The Basics article. Especially pay attention to the Add Custom Endpoint section where you can find how to create what you need.

  • My problem appears to have been a basic error (WP was reading something in what I thought was commented code). With that removed, URL resolved itself. But your link is great for problems like these, have it bookmarked. Thanks!
    – boomturn
    Mar 2, 2013 at 17:14

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.