breezy
breezy

Reputation: 1918

In Wordpress how to add a body class to all interior pages except the homepage

I want to add a class to the body tag to all pages EXCEPT the homepage. Right now I have.

<?php body_class('interior'); ?>

But it adds 'interior' to ALL pages including the home page.

What is the best standard way of adding a class to the body tag to all interior pages except the 'home page'?

Upvotes: 0

Views: 1540

Answers (2)

Marco Romano
Marco Romano

Reputation: 456

I think the best solution is write:

<body <?php if (!is_front_page()) body_class('interior'); ?> <?php body_class(); ?>>

In this way you add only class="interior" in all page except the front page, and you can save the class in the front page, otherwise in you use only the fist php code in the tag <body> in home you will not have class.

Upvotes: 0

Popnoodles
Popnoodles

Reputation: 28419

http://codex.wordpress.org/Function_Reference/is_home

<?php if (!is_home()) body_class('interior'); ?>

Unless you mean http://codex.wordpress.org/Function_Reference/is_front_page

<?php if (!is_front_page()) body_class('interior'); ?>

Upvotes: 6

Related Questions