Support » Plugins » Hacks » How do I redirect to another page after a short delay

  • Resolved wiresplus



    I want to have a thankyou page, that redirects after a short pause.

    The page id will be 432.

    I tried to add the following 7 second delay/redirect

    <?php if(is_page(432)){
    <meta http-equiv="refresh" content="7;url=[homepage url]" />

    in page.php, but no good.

    What should I be doing?

Viewing 9 replies - 1 through 9 (of 9 total)
  • I tried this too, but this just breaks the page and I get a blank screen.

    <META HTTP-EQUIV="refresh" CONTENT="<?php if(is_page(432)){7;URL=}?>">

    Moderator bcworkz


    page.php is only for content in <body> section, meta tags belong in <head> section, which is on headers.php and used for all pages, so something like your first effort makes more sense. However, is_page() is the wrong function. It only indicates if the post_type is ‘page’, not what page ID is being shown.

    To get the actual page ID, use the global $wp_query['queried_object_id']

    you need to make changes in header.php file in your theme folder.

    i suggest you to use plugin for this task.. here are a lot of free plugin available on which can redirect to specified page after short delay of time.

    @dyc I can’t find a plugin that does it, maybe I don’t know what to search for or something.

    @bcworkz – I’m not familiar with the $wp_query['queried_object_id'] bit

    Here’s header.php, down to head/>

    * The Header for our theme.
    * Displays all of the <head> section and everything up till <div id=”main”>
    * @package WordPress
    * @subpackage Twenty_Thirteen
    * @since Twenty Thirteen 1.0
    ?><!DOCTYPE html>
    <!–[if IE 7]>
    <html class=”ie ie7″ <?php language_attributes(); ?>>
    <!–[if IE 8]>
    <html class=”ie ie8″ <?php language_attributes(); ?>>
    <!–[if !(IE 7) | !(IE 8) ]><!–>
    <html <?php language_attributes(); ?>>
    <meta charset=”<?php bloginfo( ‘charset’ ); ?>”>
    <meta name=”viewport” content=”width=device-width”>
    <title><?php wp_title( ‘||’, true, ‘right’ ); ?></title>
    <link rel=”profile” href=”″>
    <link rel=”pingback” href=”<?php bloginfo( ‘pingback_url’ ); ?>”>
    <link rel=”icon” type=”image/png” href=”favicon.png” />

    <!–[if lt IE 9]>
    <script src=”<?php echo get_template_directory_uri(); ?>/js/html5.js”></script>
    <?php wp_head(); ?>


    Sorry, but where should I put the $wp_Query?

    Moderator bcworkz


    I would put it right above <\head>. Something like this (untested):

    <?php global $wp_query;
    if( 432 == $wp_query['queried_object_id']){
       echo '<meta http-equiv="refresh" content="7;url=' . get_site_url() . '" />';

    Thanks. It doesn’t work. It simply returns an entirely white screen with no website 🙁

    Hey hey!

    Fixed it: This is the code-

    <?php if(is_page( 432 )){ ?>
    <meta http-equiv=”refresh” content=”7;url=/?p=4″ />
    <?php } ?>

    This nicely dumps the meta refresh into the page header if it is page 432.
    Answer cobbled from several sources, most useful was Stack Overflow

    Thanks to all!

    Thanks for share the code, just needed that function.
    Works great in WP 3.9.1

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How do I redirect to another page after a short delay’ is closed to new replies.