I've developed a php mail() function for custom forms in a Wordpress theme. It's just a normal form that gets submitted to itself (with an empty
attribute). In functions.php, I'm including
, which checks whether POST data is present, and if so, it runs the function. In the end, the function sends an email via php's
and returns true.
This works perfectly for a single post that has a custom post type (not "post" or "page"), but when I try to use the same script on a normal Wordpress "page", it runs the function as well (and sends the email), <strong>but then it throws a 404 error.</strong> The URL in the browser address bar is unchanged (shows the permalink of the page), but it doesn't seem to find the page.
Then, if I refresh the page (without sending POST data again), i.e. by clicking on the browser address bar and hitting Enter), <strong>it shows the right page again as usual.</strong>
I'm stumped. Why would it do that?
Edit: found the solution here: <a href="https://wordpress.stackexchange.com...ess-it-loads-a-404-page-though-url-is-correct">https://wordpress.stackexchange.com...ess-it-loads-a-404-page-though-url-is-correct</a> thanks to @DigitalDesignDj's suggestion to look there.
Code:
action
Code:
inc\mail.php
Code:
mail()
This works perfectly for a single post that has a custom post type (not "post" or "page"), but when I try to use the same script on a normal Wordpress "page", it runs the function as well (and sends the email), <strong>but then it throws a 404 error.</strong> The URL in the browser address bar is unchanged (shows the permalink of the page), but it doesn't seem to find the page.
Then, if I refresh the page (without sending POST data again), i.e. by clicking on the browser address bar and hitting Enter), <strong>it shows the right page again as usual.</strong>
I'm stumped. Why would it do that?
Edit: found the solution here: <a href="https://wordpress.stackexchange.com...ess-it-loads-a-404-page-though-url-is-correct">https://wordpress.stackexchange.com...ess-it-loads-a-404-page-though-url-is-correct</a> thanks to @DigitalDesignDj's suggestion to look there.