Home Articles Uncategorized Native custom fields for SEO functionality

Native custom fields for SEO functionality

Sometimes plugins conflict and not using a plugin at all for SEO is best. Instead of using a plugin like WordPress SEO by Yoast, or All in one SEO pack, you can get the same results using custom fields. With SEO all you really need access to are the <title> and <meta name="description">.

While I think the SEO plugin by Yoast is the best, sometimes I have to revert back to the old custom fields approach. Here’s the code I use. Both are conditional.

The Title

<?php if(get_post_meta($post->ID, "title", true)): ?>
<title><?php echo get_post_meta($post->ID, "title", true);?></title> 
<?php else: ?> <title><?php wp_title(''); ?></title>
<?php endif; ?>

To use, either add or select the name (title) from the custom field box in the post/page edit page and enter the value.

The Meta Description

<?php if(get_post_meta($post->ID, "description", true)): ?>
<meta name="description" 
content="<?php echo get_post_meta($post->ID, "description", true);?>" /> 
<?php endif; ?>

To use, either add or select the name (description) from the custom field box in the post/page edit page and enter the value.