lundi 9 mai 2016

Wordpress plugin that redirects any 404 page to home page

I am creating a simple plugin that will create a 301 redirect for 404 page.

This is what I have so far:

add_action('wp_head', 'waxed_wp_redirect');
function waxed_wp_redirect() {
  if ( is_404() ) {
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: /?page=404");
    exit();
  }
}

But it doesn't work and I think its because the header function needs to run before the page is loaded.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire