WordPress puzzles

I’ve spent much of today problem-solving a website project that I’m working on. I’ve decided to use WordPress to manage the site but need it to do a couple of things:

Navigation

The site has a number of sections, e.g. Home, About us, News, What we do, Contact us, etc. and I’d like the site to show the top-level navigation as a horizontal navigation bar just beneath the header, but show only sub-navigation for the current section in the right-hand sidebar.

In other words, if we’re in the About us section I want the right-hand navigation to show only sub-menu items from About us, e.g. Our History, How we are funded, Our year, etc.

I’ve managed this very simply using the Fold Page List plugin.

Custom styles

Next, I want to be able to apply a different coloured theme to each section, e.g. Home is green, About us is orange, News is red, etc.

In a good old fashioned hand-coded site I’d simply serve up a different CSS style sheet for each section, e.g. home.css would style the relevant parts of the page green, aboutus.css would style everything orange, etc.

Page-by-page

But how to do this with WordPress? I’ve found a plugin that will allow me to specify a CSS style sheet for each page, but this is done on a page-by-page basis rather than globally.

Page Template

I’d really like to be able to use the WordPress Page Template functionality for this — so when I select which Page Template is used, e.g. “About” then it automatically inserts the appropriate CSS file in the page header.

I suspect that I’ll have to write something custom using the wp_head() hook. I’d really like to write a plugin to do this, but my PHP skills aren’t quite as 1337 as I’d like them to be.

Ideally it would offer a configuration screen that reads in the template files, lists them on a page and allows me to specify which CSS file to link to which. Then the plugin does the magic automatically.

I’ll get working on this right away …

Published by

Gareth Saunders

I’m Gareth J M Saunders, 46 years old, 6′ 4″, father of 3 boys (including twins). Latterly, web architect and agile project manager at the University of St Andrews and warden at Agnes Blackadder Hall. Currently on sabbatical. I am a priest in the Scottish Episcopal Church, and I sing with the NYCGB alumni choir.

2 thoughts on “WordPress puzzles”

  1. I’m actually following this!
    Before I read it, I was going to chip in with “make page .css files for each seciton” but you knew that.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.