As the Topic title suggests, I'm wondering how to take the name that I give whatever new page i create in wordpress and assign that name as the value of class attribute for the <body> tag...
Any takers?
As the Topic title suggests, I'm wondering how to take the name that I give whatever new page i create in wordpress and assign that name as the value of class attribute for the <body> tag...
Any takers?
for instance, adding 'page-' before the page slug (using the page slug rather than the page title as this could contain spaces and other non-css characters):
<?php if(is_page()) { $page_name = 'page-'.$post->post_name; } ?>
<body <?php body_class($page_name); ?>>
Thanks for the help. I've added that to header.php which I assume was the thing to do (I'm new to this). I've created a new page (named "page leon") and upon viewing the page's source code I get the following: <body class="page page-id-14 page-template-default page-page-leon pagename-page-leon">
So, would I be correct in guessing that I can (or more importantly, should) use either "page-id-14", "page-page-leon", or "pagename-page-leon"? -- I've tried using the named options as class selectors in the css and it works!..I'm just curious--being new to this-- as to whether this is the best way to go or not.
Thanks very much again for your help...the progress I've made thanks to you is far beyond what I would have accomplished without.
Kind rehards
you are doing it right ;-)
You must log in to post.