Forums / General Questions / How do I add custom meta tags to individual pages - NOT title, keyword, description

How do I add custom meta tags to individual pages - NOT title, keyword, description

Views: 1,960

Results 1 to 3 of 3
20 Jun 2012, 2:57 PM
#1
ardhill avatar

ardhill

New Zenner

Join Date:
Dec 2007
Location:
Belfast, N.Ireland
Posts:
99
Plugin Contributions:
0

How do I add custom meta tags to individual pages - NOT title, keyword, description

Hi

I am trying to add some custom meta tags (open graph for facebook) to individual pages. But can't figure out how to do it.

I know how to add custom Title, Keywords and Description meta tags, but that is NOT what I want to do.

I want to add different tags to different pages, and not the same ones common to all pages. So I can't just hard code the tags to html_header.php

An example of a meta tag I want to add would be:
<meta property="og:image" content="http://MyDomain.com/Product-Image.gif" />

Does anyone know how to do this?

Thanks.

Paul

20 Jun 2012, 3:04 PM
#2
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Re: How do I add custom meta tags to individual pages - NOT title, keyword, description

Insert the bold text below inbetween the two tags in your html_header.php file..

<title><?php echo META_TAG_TITLE; ?></title>

**<meta property="og:title" content="<?php echo META_TAG_TITLE; ?>" />
<meta property="og:type" content="product" />
<meta property="og:site_name" content="<?php echo STORE_NAME; ?>" />
<meta property="fb:admins" content="522158762" />

<?php if (isset($_GET['products_id'])) { // use products_image if products_id exists $facebook_image = $db->Execute("select p.products_image from " . TABLE_PRODUCTS . " p where products_id='" . (int)$_GET['products_id'] . "'"); $fb_image = HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $facebook_image->fields['products_image']; } if ($fb_image == '') { // if no products image, use the default image if enabled $fb_image = 'insertgenericpichere.jpg'; } if ($fb_image != '') { ?> <meta property="og:image" content="<?php echo $fb_image; ?>" /> <?php } ?>** <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>" />
20 Jun 2012, 3:26 PM
#3
ardhill avatar

ardhill

New Zenner

Join Date:
Dec 2007
Location:
Belfast, N.Ireland
Posts:
99
Plugin Contributions:
0

Re: How do I add custom meta tags to individual pages - NOT title, keyword, description

dgent - not an answer to my actual question - but you did give me the answer to what I was ultimatly trying to achieve - Thank you :)

It works great, but if I may just add an instruction for anyone else reading this...

edit the floowing line with the 'full url path' of the image you want as a default image if no product images are being pulled from the page. In my case, I used a logo.
$fb_image = 'insertgenericpichere.jpg';

Thanks dgent,

Paul

dgent:

Insert the bold text below inbetween the two tags in your html_header.php file..

<title><?php echo META_TAG_TITLE; ?></title>

**<meta property="og:title" content="<?php echo META_TAG_TITLE; ?>" />
<meta property="og:type" content="product" />
<meta property="og:site_name" content="<?php echo STORE_NAME; ?>" />
<meta property="fb:admins" content="522158762" />

<?php if (isset($_GET['products_id'])) { // use products_image if products_id exists $facebook_image = $db->Execute("select p.products_image from " . TABLE_PRODUCTS . " p where products_id='" . (int)$_GET['products_id'] . "'"); $fb_image = HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $facebook_image->fields['products_image']; } if ($fb_image == '') { // if no products image, use the default image if enabled $fb_image = 'insertgenericpichere.jpg'; } if ($fb_image != '') { ?> <meta property="og:image" content="<?php echo $fb_image; ?>" /> <?php } ?>** <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>" />