Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
in Plugins by
edited by

I like to target specific main areas (.qa-main) by their body class. Different styles on different sites, but .qa-main is persistent. That was a tip of gidgreen once.

However, problems occur when I have a plugin page. Each plugin page has the body class ".qa-template-plugin".

How can I specify a custom CSS name for the body tag?

1 Answer

+2 votes
selected by
Best answer

Call qa_set_template(...) with the name you want to use.

In function process_request($request) I added:
    // set CSS class in body tag

Nice! Thanks a lot :-)
Extension of the question: How can I add a custom CSS class to a "custom page". Each custom page has only ".qa-template-custom" for now.
I thought you would need to do this with a layer which modifies the body_tags() function.
I am using the "advanced theme" and override function body_tags() as you suggested. This works:

/* override to add custom CSS class in body tag */
function body_tags() {
    $this->output('CLASS="'.$class.' qa-body-js-off"');

(!) Thanks ;)
Now I can get rid of all CSS styles in plugin pages and custom pages, and only use a global stylesheet. Plus another stylesheet for mobiles! ... check it out on your smartphone: http://www.gute-mathe-fragen.de/