How to 301 private posts rather than 404?

Sorry guys, I found my answer: add_action(‘wp’,’redirect_stuffs’, 0); function redirect_stuffs(){ global $wpdb; if ($wpdb->last_result[0]->post_status == “private” && !is_admin() ): wp_redirect( home_url(), 301 ); exit(); endif; } Posts/Pages are removed from the sitemaps, but the page still shows up on the site so that it can get 301’d.

Where does wp_redirect need to be placed to make it work?

Once you’re in the template it’s too late, as headers have already been sent. You have to hook earlier in the request to check, like the template redirect hook: add_action( ‘template_redirect’, ‘wpse52455_redirect’ ); function wpse52455_redirect(){ // do your check and call wp_redirect here } Note that this will get called on every request, so you … Read more

wp_redirect not working after submitting form

You can only use wp_redirect before content is sent to the browser. If you were to enable php debugging you’d see a “headers already sent” error due to get_header() on the first line. Rather than process the form in the template, you can hook an earlier action, like wp_loaded, and save some queries to the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)