Forums

How to add a meta tag to one page only (3 posts)

  1. waterprism
    Member
    Posted 8 months ago #

    Hi,

    I want to add something into the head section of just one specific page in my blog (a page, not a post), a meta tag like this --

    <meta http-equiv='Refresh' content='0;url=javascript:history.go(-1)'>

    I've tried the following in my header --

    <?php
    if (is_single()) {
         if ($custom_header = get_post_meta($post->ID, 'custom_header', true)) {
         echo $custom_header;
         }
    }
    ?>

    -- and created a custom field for that page called custom_header with the meta as the value, but that hasn't worked. How can I add that meta tag to just one specific page?

    Thanks.

  2. alchymyth
    The Sweeper
    Posted 8 months ago #

    one specific page

    the conditonal tag would be is_page()
    http://codex.wordpress.org/Function_Reference/is_page

    is_single() is only true for single posts.
    http://codex.wordpress.org/Conditional_Tags

    also, the if statement should have double equal signs == for the comparison

  3. waterprism
    Member
    Posted 8 months ago #

    Thanks

Reply

You must log in to post.

About this Topic