Hi. I am trying to insert some keywords into my page titles for SEO reasons (per client request). My page structure is already set and i don't want to mess with the naming structure, as i don't need to edit all the pages. Here's what i've tried to do:
I'm trying to achieve this structure for my titles:
(page keyword) | Blog Title | (general keyword)
I've set custom fields in my pages and posts called page-keyword and general-keyword, and echoed them inside the title tag if they exist. However, for the category archives, i can't add custom fields (right?) so i'm setting variables in my category templates before the call for the header, and trying to echo them in the title tag. The custom fields are working fine, and they output both of my keywords in the title. However, the keywords i'm trying to set with variables are not working. Here's some of my code:
in my header.php:
<title>
<?php if(get_post_meta($post->ID, "page-keyword", true)) { ?>
<?php echo get_post_meta($post->ID, "page-keyword", true); ?>
<? } else { ?>
<? echo $pageKeyword ; ?>
<? } ?>
| <?php bloginfo('name'); ?>
<?php if(get_post_meta($post->ID, "general-keyword", true)) { ?>
| <?php echo get_post_meta($post->ID, "general-keyword", true); ?>
<? } else { ?>
| <?php echo $generalKeyword; } ?>
</title>
and in my category templates, something like this at the beginning....
<? $pageKeyword = "My Page Keyword"; ?>
<? $generalKeyword = "My General Keyword"; ?>
<?php get_header(); ?>
Can anyone tell me why those variables aren't being passed or echoed...is my syntax wrong?