Setting up WordPress as a CMS – part 2

In part 1 I discussed how cleaning up the Dashboard in WordPress by removing excess admin panels and editor sections makes it easier to use, especially for users who are new to WordPress. In this part I’ll be discussing how to add options for excluding pages from navigation and how to add alternate titles.

Exclude Pages from Navigation

I often want to add Pages to my WordPress site, without showing it in wp_list_pages(). So far WordPress doesn’t have an option for excluding Pages from navigation menus without setting Visibility to Private (which makes them unavailable for non-logged-in users). For this we have to use a Plugin: Exclude Pages. This plugin adds a checkbox to the Page Editor; “Include this page in menus”. Simply uncheck this to exclude Pages from the page navigation that users see on your site.

Alternate Titles

When creating Pages in WordPress, what you put in the Title Field will show up both in navigation and as a title on the website. This can be very impractical, not to say downright frustrating. Often I want the menu item to be “About Us”, but the Page title to be “Who We Are”, or something of the same. Not possible in WordPress out-of-the-box. The sollution is Custom Fields. In the Page Editor, add a new custom field called “alttitle”. Then edit your page.php, and replace <h2><?php the_title();  ?></h2> with:

<?php $alttitle = get_post_meta($post->ID, 'alttitle', true); ?>
<h2><?php if(!$alttitle) { the_title(); } else { echo $alttitle; } ?></h2>

That’s it. The code checks if an alternate title is exists, and if so, displays it. Otherwise the default Page title is displayed.

Make an Alternate Title Section in the Editor

If you have hidden the custom fields section from your users, or just simply want to make the sollution more elegant, you can use the More Fields plugin i mentioned in part 1. Here’s how to do it:

  1. Install and activate the plugin
  2. Go to Settings > More Fields and click “Add a new box!”
  3. In Box title put “Alternate Title”, and select “Left” in the Position pull-down, save
  4. Click the “Add new field!” button
  5. In Key put “alttitle”, in Title put “Alternate Title is used as page heading, while Title field (above) is used for navigation items”, leave the rest as is, save
  6. Click “Manage post types” in the top menu, click “Page”, scroll down to the bottom and check the checkbox next to Alternate Title, save

You will now have a new editor section in the Page Editor, where you can write alternate titles for your Pages.

alttitle_dump

One thought on “Setting up WordPress as a CMS – part 2

  1. Dmytro

    Stian, thank you so much for the Alternate Title code. I completely agree with you about WordPress’ original impracticality, especially when I specifically want the navigation titles of my blog to be one word (ex. Home, About, Contact), but I obviously want a longer title on the actual page. What a lifesaver you are! :)

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>