How to add extra classes to Wordpress's body element?
In the default Wordpress template, there is this in header.php
.
<body <?php body_class(); ?>>
This echos some useful hooks for CSS and JavaScript. Some example output is
<body class="page page-id-45 page-template page-template-gallery-php">
Is it possible, within the header.php
even, to add my own classes i开发者_如何学编程n addition to what is there?
Specifically, I'd like to do a quick strstr
on $_SERVER['HTTP_USER_AGENT']
and add a class if the device is an iDevice.
I figure I could do it with JavaScript, but still being able to know how to add my own classes would be useful nevertheless.
I believe you can just pass the extra class-name as a parameter, i.e.
<body <?php body_class('myclassname'); ?>>
...which seems to be confirmed here.
精彩评论