Ready to get started?Download WordPress


[resolved] How do I redirect to another page after a short delay (9 posts)

  1. wiresplus
    Posted 5 months ago #


    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?

  2. wiresplus
    Posted 5 months ago #

    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=http://kjscreations.co.nz/}?>">

  3. bcworkz
    Posted 5 months ago #

    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']

  4. DYC - The Voice Of Generation
    Posted 5 months ago #

    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 wordpress.org which can redirect to specified page after short delay of time.

  5. wiresplus
    Posted 5 months ago #

    @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

  6. wiresplus
    Posted 5 months ago #

    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="http://gmpg.org/xfn/11">
    <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?

  7. bcworkz
    Posted 5 months ago #

    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() . '" />';
  8. wiresplus
    Posted 5 months ago #

    Thanks. It doesn't work. It simply returns an entirely white screen with no website :(

  9. wiresplus
    Posted 5 months ago #

    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!


You must log in to post.

About this Topic