Long/short headings (or title tags) using WordPress Custom Fields


[ This post is now largely if not entirely redundant now thanks to WordPress 3 menu options ]

Problem: WP titles are too long to fit in your navigation.

Solution:

Make the title short enough to fit in the navigation and then add a Custom Field into your post (in the example bellow it is set as “heading”) then edit your template file to render the longer version (“heading”) on the page.

Example:

In the Loop of  your template swap out

<h1><?php the_title(); ?></h1>
<?php the_content(); ?>

for:

<h1><?php// If has a custom field of heading ; then use that:
$customField = get_post_custom_values("heading");
if (isset($customField[0])) {
echo $customField[0];
} else {
the_title();
} ; ?></h1>
<?php the_content(); ?>

Hat-tip: Smashing Magazine

,

  1. No comments yet.

You must be logged in to post a comment.