making categories look like pages

Posted by admin on December 5th, 2009 · Filed under admin


The categories template in our theme does a nice job of listing posts, and it’s the preferred way to show time-based things on the CAMRA site. However, categories don’t show up in our banner menu, because (currently, at least) it only looks for PAGES.

There are two ways to override this. In both cases we first make a page with the right name, e.g. “news”.

Then… either edit the .htaccess file to do a redirect, like this:

RedirectMatch "^/news/$"  http://wp.camravancouver.ca/category/news/
Redirect /news/index.php  http://wp.camravancouver.ca/category/news/

(You don’t REALLY need the second one, but it doesn’t hurt to be anal…)

Or make an adjustment to the JQuery code that massages the page list into our menus, in the Header template:

jQuery("#dropmenu a[href$='/news/']").attr("href","/category/news/");

All the latter does is add the category to the menu. This can be useful in certain situations, but the former solution is actually better, because it takes the original page out of circulation. In the latter case, you can still go to “/news/” and NOT see the category listing.

In either case, best to put text like this into the page itself, as a backup:

If you see this page, something is wrong with our redirects!! :-(

You really want to go here instead.

Could probably put a trigger in there somehow to alert someone if such a page IS ever seen.