Answer the question
In order to leave comments, you need to log in
How do I redirect to the same page in Wordpress?
here is my code part in function.php:
if (!empty($_POST['send_email']) and !empty($_POST['send_mess'])):
wp_mail('[email protected]', 'письмо с сайта', $_POST['send_mess']); //, $headers, $attachments
wp_redirect( get_permalink() );
exit;
endif;
}
Answer the question
In order to leave comments, you need to log in
Do you initially have code sticking out in functions.php, not defined in a callback function that is hung on some kind of hook? Then you are doing everything wrong. Your code is executed every time any page is loaded , both on the front and in the admin. And it is executed when the theme files are loaded. Hang the code on template_redirect. Instead of get_permaink use $_SERVER['HTTP_REFERER'].
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question