Jan 27

I don’t know about you, but the short title necessary to fit the page name in the list of pages across the top navigation bar, really chaps my butt.

You have to keep the page *name* small (like one or two words max), but that means the *title* is displayed with that one or two words. And before you write in to tell me there are plugins to override the browser title area for a page, let me mention, that’s not what chaps me. I mean the main title displayed on the page.

Let me give you an example you have probably seen: There is an ABOUT page, and even though you can stuff *About Cenay Nailor* in the browser title, only About is displayed on the actual page.

Like most programmers plagued by some stupid behavior, I came up with a way around it. Let me share that with you.

Add a custom field to the page (in my example, I named it customtitle) and place your more descriptive text here. Then pop over to the theme editor and update the page.php (for most WordPress installations and themes) like so:

(Original line)

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

(Replace with)

<h1><?php $key="customtitle"; echo get_post_meta($post->ID, $key, true); ?></h1>

I also added the original line just below my new line, but changed the h1 to an h3 tag. This gives me custom text in the larger font, and the actual page title in the smaller header tag.

One Response to “Customizing WordPress Page Titles”

  1. Wilbur Gaer Says:

    I definitely wanted to post a simple note to thank you for those unique tips you are giving out here. My extensive internet research has finally been paid with sensible points to share with my relatives. I would admit that we site visitors actually are unequivocally lucky to be in a magnificent community with very many special professionals with valuable concepts. I feel very grateful to have seen your weblog and look forward to tons of more entertaining moments reading here. Thanks a lot once again for everything.

Leave a Reply