Submit Your Article Forum Rules

Results 1 to 6 of 6

Thread: Meta tag in WordPress (PHP coding)

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    3

    Meta tag in WordPress (PHP coding)

    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.

  2. #2
    Moderator HTMLBasicTutor's Avatar
    Join Date
    Apr 2010
    Location
    Canada
    Posts
    975
    You need to add this to the header.php file so it is placed between the opening and closing head tags.

    You could just add the line to the header.php file and it will appear in the head section of all pages. (easiest way)

    If you need it just for one page you will need the page id and then put a condition in the header.php file for when that page is presented. Some examples here: A Single Post Page

    Or... fix the coding in the page so you don't need the line at all.
    Accrete Web Solutions - Search engine friendly websites, ecommerce websites & blogs
    Web Page Mistakes - Web page mistakes with solutions
    HTML Basic Tutor - HTML help to learn HTML basics

  3. The following user agrees with HTMLBasicTutor:
  4. #3
    Junior Member
    Join Date
    Aug 2011
    Posts
    3
    Forgive me, my programming skills are not great. The meta tag can only be on one page. The page ID is 115, how would I add the code to include this page ID for placement in the header.php file.

    This is required as I'm showing an iframe on a specific page, the iframe CSS from the host site renders fine on all browsers except IE9. The above meta tag fixes this.

    Thanks,
    Peter.

  5. #4
    WebProWorld MVP morestar's Avatar
    Join Date
    Jun 2007
    Location
    Toronto, Ontario (Burlington)
    Posts
    4,259
    Try this, in header.php:

    Code:
    <?php
    
    
    if (is_page(1)) {
    
    
    echo "<meta http-equiv="X-UA-Compatible" content="IE=8" />";
    
    }
    
    ?>
    This should work but unfortunately sometimes doesn't work for me while it's worked for others.

    The number 1 you see will be your page ID. All you need to do to get the page ID is go to your list of pages, and put your cursor on the "edit" link and you'll see the page ID in the URL which is displayed in your status bar, at the left/right hand side of the screen. Replace your ID with that one and you should be set.
    Join a free dating site and meet single people in your area.
    Submit your content at my content publishing site and promote your business, services or opinions.

  6. #5
    Junior Member
    Join Date
    Aug 2011
    Posts
    3
    Thanks Morestar, worked brilliant, just had to change the first and last quotes to single quotes and working great!

  7. #6
    WebProWorld MVP morestar's Avatar
    Join Date
    Jun 2007
    Location
    Toronto, Ontario (Burlington)
    Posts
    4,259
    Found a plugin that works great, I just needed it cause I'm doing some a/b/c tests and I needed to add the Content Experiment code into certain pages. Sweet.

    I even changed the code so when you're on a post/page page editing it, the box that allows you to add your custom header content isn't a regular text box, now it's a text area box.

    I don't think you need to worry about the plugin's updates but we'll see if it fails one day.

    so freeze, delete the code in the header, and just go to the page in question, edit it, and at the bottom paste in your custom header line of code.
    Join a free dating site and meet single people in your area.
    Submit your content at my content publishing site and promote your business, services or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •