Reputation: 69
I have a custom WordPress theme on which I display different backgrounds for different pages.
E.g.
<body <?php body_class(); ?>>
<?php if (is_page('about')) : ?>
<body style="background:url(background-stripe.gif); background-repeat: no-repeat;">
<?php endif; ?>
I am currently trying to get this applied to a custom post type (single) page as well , what is the best method to have that achieved?
Upvotes: 0
Views: 162
Reputation: 357
is_singular is the conditional tag for specific post types. You could use that if you don't want different backgrounds for all single posts/different post types.
Having said that, I would use body_class as already suggested.
Upvotes: 1
Reputation: 17797
Instead of these conditions I'd use the body_class() function on the body
tag. It adds classes for custom types which should suffice, but if you need more you can add a class with a filter in your page template. Then you only have to set the background in the CSS file with body.custom-page
or something like that.
Upvotes: 1