Broken navigation in WordPress .. and one way to fix it

After upgrading my sites to WordPress 3.3, as well as updating a few themes, I noticed page navigation was broken in some of them.

Namely, the base path was repeated in the URL. Instead of using a URL such as ‘/linfa/create/page/2’ for older posts, the URL used was ‘/linfa/create/linfa/create/page/2’.

The odd thing was that the bug did not happen all the time. Some themes were affected. Some were not. And the same theme would appear broken on one computer and not on another.

I tracked down that behavior to a missing trailing ‘/’ in the URL for the Home link in a theme.

For example, if a theme is using this in its Header.php file :

[code]<a href="”>[/code]

The link to the home page would be missing a trailing ‘/’ and would in turn break page navigation with older entries.

A solution is to replace the call for home_url by :

[code]<a href="”>[/code]

The ‘/’ parameter ensures the URL is properly closed and will not break navigation.

So … check your headers and make sure your themes are updated.

Leave a Reply

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

%d bloggers like this: