You could define 5 different CSS styles with names like style1, style2, etc, with each trailing number equating to one of your five Page Parent’s IDs.
Now let’s assume you’re using the default template. Open your page.php file and find the following line of code:
<div class="post" id="post-<?php the_ID(); ?>">
And replace it with the following:
<div class="post style<?php echo ($post->post_parent); ?>" id="post-<?php the_ID(); ?>">
That bit of PHP after the “style” piece I added will get the Parent ID of the current page and add it directly after the word “style”. So you’ll have your various style1, style2, style3, style4, etc.
From there you can define those styles as you’d like in your stylesheet.
That should be enough to get you started.
thanks.
the idea is not to be dependant on the ids, as pages might be added and deleted and the id i wont be able to get back.
i imagine i could try to use permalink as refering to the page.
or maybe there is even a better way how to do that?
could i specify it somewhere in the page template so i could choose different stylesheets? i would not want to put in one file and do all the additional markup.
separate stylesheets sounds better, doesnt it?
thanks,
h
Hmmm, I was under the impression from your original post that you were going to have 5 main pages, and the rest would be subpages and subsubpages, so doing it the way I specified would eliminate you from having to use page templates and page parents.
If you want/need to use page templates then you can define any CSS you want with the different page templates.
Hi clicknathan,
I’m designing The Real Fight Club’s new website and I want different header images for each section of the site and i9ts respective sub-pages. That snippet of code is exactly what I was looking for!
Thanks