views:

14

answers:

1

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 in 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.

+1  A: 

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.

Matt Gibson
Thanks! +1 will test it in a few hours...
alex