A non wordpress PHP file has this kind of code:

<form class="someclass" action="page-contact.php" method="post">

But when in WordPress it doesn’t work.

suppose we are here(a WordPress page or a post): www.sample.com/somepage/

The above page is using the page-contact.php template.

Then the above when the to submit button of the contact form is triggered takes to:


This generates an error that 404 not found(because that link doesn’t exist). what is the solution so that it(action) works in WordPress?

I tried the solution posted here → How to handle form submission?

  1. But that solution doesn't work.
  2. Even if had worked than which theme author will put an action file in wp-admin because the path is shown their belongs to wp-admin →

action="<?php echo admin_url('admin-ajax.php'); ?>"

In my case, the admin-ajax.php file will be the same template/page file where the swiftmailer code is there with SMTP settings to send an email.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.