Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'body_class', 'sk_singular_body_class' );
- /**
- * Adds a css class to the body element
- *
- * @param array $classes the current body classes
- * @return array $classes modified classes
- */
- function sk_singular_body_class( $classes ) {
- if ( is_singular() && has_post_thumbnail() ) {
- $classes[] = 'has-thumbnail';
- }
- return $classes;
- }
- add_action( 'wp_head', 'sk_singular_body_bkgrd' );
- function sk_singular_body_bkgrd() {
- if ( !( is_singular() && has_post_thumbnail() ) ) {
- return;
- } ?>
- <style type="text/css">
- body {
- background-image: url( <?php echo wp_get_attachment_url( get_post_thumbnail_id() ); ?> );
- }
- </style>
- <?php }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement