Meta tag in Wordpress (PHP coding)

Discussion in 'PHP' started by frozenwaste, Aug 2, 2012.

  1. #1
    Hi,

    I'm having issues trying to add a meta tag to a single "page" in WordPress.

    The tag is:
    <meta http-equiv="X-UA-Compatible" content="IE=8" />

    I've tried numerous plugins but they only seem to help with meta keywords, title, description and robots, none for the above.

    I've been advised to use the Custom Fields route, but my PHP skills are limited!

    Any ideas?

    Thank you,
    Peter.
     
    frozenwaste, Aug 2, 2012 IP
  2. RAND0M1ZER

    RAND0M1ZER Active Member

    Messages:
    142
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Do you want this tag to be everywhere on your site or just on a particular post type? or only one one page?
     
    RAND0M1ZER, Aug 2, 2012 IP
  3. frozenwaste

    frozenwaste Member

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #3
    Just on one single page. The page in question contains an iframe which doesn't render CSS properley on IE9. This meta tag fixes the issue but I only want this single page to render as IE8.
     
    frozenwaste, Aug 2, 2012 IP
  4. RAND0M1ZER

    RAND0M1ZER Active Member

    Messages:
    142
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #4
    The easiest way I know of would be to create a custom page template. You can do this buy taking the page.php file and saving it as something like iframe-page.php, make sure at the top you put:

    <?php
    /*
    Template Name: Contact Form
    */
    ?>
    PHP:
    Wordpress uses this comment format to determine the name of the custom template. Now where it says:

    <?php get_header(); ?>
    PHP:
    You need to remove this and replace it with the entire contents of your header.php file

    Then you can put the tag you want within the head tag.

    Last thing you need to do is go to your Wordpress control panel and change the template of that page to the custom one.
     
    RAND0M1ZER, Aug 2, 2012 IP
  5. frozenwaste

    frozenwaste Member

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #5
    Thanks RAND0M1ZER,

    Will give it a go, just checked my page templates and none of them seem to call the header though, site is based on StudioPress Genesis framework which gets header from functions file.
     
    frozenwaste, Aug 2, 2012 IP
  6. RAND0M1ZER

    RAND0M1ZER Active Member

    Messages:
    142
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #6
    Oh I see, the frameworks are a bit different. I think the other option would be to use a filter of some kind in your functions.php file.

    I'm not an expert with this but maybe someone else can help you create a filter based on the page's slug and inserting the tag you want into head area.

    It shouldn't be more than a few lines.
     
    RAND0M1ZER, Aug 2, 2012 IP