Update body class based on theme as well as a html attribute
I just started using wordpress. Now I'm trying to create a theme for a static web page I wrote.
For that web page I'm using barbajs, which is why I have a html tag (in my case a section tag) with a custom data-namespace attribute.
Also I use body classes for each page.
So basically a page looks something like that:
body class="page-about"
main
section data-namespace="about"
/section
/main
/body
I was able to use a function from this question to append a body class, but since I don't really need all the crap classes that wp comes with (like page page-id-7 page-template, etc), I'd like to create a custom function.
So basically I want something like that:
In the template I'd like to define a namespace variable, or something similar, which will then be used by a function to place wherever I need it.
something like that:
?php
/* Template Name: About Template */
$namespace = 'about';
?
body class="page-?php get_namespace() ?"
main
section data-namespace="?php get_namespace() ?"
/section
/main
/body
The get_namespace function should then be defined in the functions.php.
Can someone help me with the function, or recommend a better way to do it?
I appreciate all the help!
UPDATE
Now that I've worked on a couple wordpress pages, I understand the way bodyclass operates better. My initial Problem was pretty much only, that I used my own page class which I can replace with the ones created by wordpress in the css, I guess I should simply use static text for the data-namespace attribute, which works fine, as long as I don't include that section in the header.
Topic namespace body-class templates Wordpress
Category Web