You’ve followed the setup instructions perfectly. You’ve done a bang-up job creating your Archives and About pages, but your links in the navigational bar still don’t work. What’s wrong? How do you fix this?
The header code was constructed under the assumption that your permalink structure ends with the post name (for more info, read this section of the WordPress Codex). Unfortunately, the WordPress default permalink structure is not constructed this way. Thus, whenever someone who is using the default permalink structure attempts to use the links in the navigation menu, they will encounter this problem (i.e. their links won’t work).
The WordPress default permalink structure carries absolutely no semantic meaning in terms of the URL construct.
At this point, you may be asking yourself, “Why did he create the theme to work with a permalink structure that differs from the default structure?” Luckily, I have a good answer this time! The WordPress default permalink structure carries absolutely no semantic meaning in terms of the URL construct. It’s got question marks, equal signs, and numbers, and it’s just plain ugly. The “pretty permalink” structure, on the other hand, carries quite a bit of pertinent information with it, including chronology and a shorthand version of the post name itself. Most WordPress “purists” opt for this type of permalink structure because there is a growing movement on the web to use URLs that actually mean something to humans (rather than just to servers).
Fortunately, there are two possible solutions to this problem, and you can implement whichever one best suits your needs and abilities.
Change your permalink structure.
- Log in to your WP Administration panel and click on the Options link.
- Next, click on Permalinks in the sub-navigation menu.
- Do one of the following:
- Choose the second option (Date and name based)
- Or choose the fourth option (Custom), and then write
/%postname%/in the associated text field
- Click on the Update Permalink Structure button. If you’re lucky, WordPress will automatically update your directory structure, and no further editing will be necessary. If you’re not so lucky, you’ll have to do a minor
.htaccessmodification in order to complete the permalink structure transition.
In the event that you have to do an
.htaccess mod, WordPress will actually supply you with the necessary code to make everything happen. Simply copy that code, and then start a new document in the text editor of your choice (but not the standard Notepad that comes with Windows! I recommend TextPad). Paste the code in the new document, and save the file as simply “.htaccess” (the preceeding period is crucial). Once you’re done, upload that file to your core WordPress directory folder.
Obviously, if you already have an
.htaccess file, then you’ll have to concatenate the existing file with this new snippet of code that WordPress has provided. If this paragraph sounds like Greek to you, then you probably don’t need to worry about this step 🙂
I realize that this explanation is somewhat cryptic, and if you’d like some more information, you ought to check out what the WordPress Codex has to say on this topic.
Change your header file to work with your directory structure. If you don’t want to change your permalink structure as indicated above, then you can always modify the header to accommodate your newly-created Archives and About pages. Whenever you create a page, it is assigned a unique identity number. In order to make the links in your navigation menu work correctly, all you have to do is modify the destinations of the Archives and About links in the
header.php template file.
<li><a class="archives" href="http://path_to_your_blog/archives/">archives</a></li>
<li><a class="about" href="http://path_to_your_blog/about/">about</a></li>
After modification, it should look something like this (changes indicated in red):
<li><a class="archives" href="http://path_to_your_blog/?page_id=3">archives</a></li>
<li><a class="about" href="http://path_to_your_blog/?page_id=2">about</a></li>
The numbers above (3 and 2) are used as examples only. The unique IDs of your Archives and About pages may be different, so you need to verify them on your own WordPress installation. Here’s how you do that:
- In your WordPress Administration panel, click on the Manage link in the navigation menu.
- Next, click on the Pages link in the sub-navigation menu.
- The leftmost column is labeled ID – enter the appropriate value for each page into your
header.phpfile, and your links will work!
If you still have problems, please let me know in the comments…Thanks!