Temporary redirect prevents getting $_POST array

A brief background on the behavior of 3xx status codes A 302 redirect is treated differently across browsers. Partially because of the variance of 302 in HTTP/1.0 and HTTP/1.1. HTTP 1.1 302 Found specifies that the request must not automatically be reprocessed at the returned location URI unless it can be confirmed by the user. … Read more

Cannot get redirect working

none of those conditionals will work at after_theme_setup. Look at the Action Reference page in Codex for the order actions are executed in a request. Try hooking template_redirect instead.

Redirecting old site links to new site

I don’t think this needs any WordPress at all. I would set up a single .php script setting the headers as such: header(“HTTP/1.1 301 Moved Permanently”); header(‘Refresh: 5; URL=http://jill.com/name_of_the_article’); And then whatever content you wish. Then I would set up a redirect to the said .php script. You would have to fetch the particular name … Read more

template_redirect to accompany with a shortcode

The answer below doesn’t directly answer your question but provides a possible alternative solution. Drop has_shortcode( $post->post_content, ‘my-shortcode’ ) statement. There is no need to check this if you are validating nonce. So the validation should look something like this. function project_registration_login_redirection(){ if ( !isset( $_POST[‘my_submit’] ) ) { return; } // form validation here … Read more

So how to redirect category to a page of the same name if it exists?

get_page_by_path does something similar: function pagefromcat_template_redirect() { if ( ! is_category() ) { return; } $category = get_queried_object(); $page = get_page_by_path( $category->slug ); if ( $page instanceof WP_Post ) { $url = get_permalink( $page ); wp_safe_redirect( $url, 301 ); } } add_action( ‘template_redirect’, ‘pagefromcat_template_redirect’ );

Redirect a password protected page?

Tom J Nowell confirmed what was happening. Inserting wp_redirect in a template causes the page either to partially load or not load at all. It needed to be placed before the opening <html> to work as it would load everything before </head> then stop.