Advertisement
srikat

Untitled

Mar 28th, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. add_filter( 'body_class', 'sk_singular_body_class' );
  2. /**
  3. * Adds a css class to the body element
  4. *
  5. * @param array $classes the current body classes
  6. * @return array $classes modified classes
  7. */
  8. function sk_singular_body_class( $classes ) {
  9.  
  10. if ( is_singular() && has_post_thumbnail() ) {
  11. $classes[] = 'has-thumbnail';
  12. }
  13.  
  14. return $classes;
  15. }
  16.  
  17. add_action( 'wp_head', 'sk_singular_body_bkgrd' );
  18. function sk_singular_body_bkgrd() {
  19.  
  20. if ( !( is_singular() && has_post_thumbnail() ) ) {
  21. return;
  22. } ?>
  23.  
  24. <style type="text/css">
  25. body {
  26. background-image: url( <?php echo wp_get_attachment_url( get_post_thumbnail_id() ); ?> );
  27. }
  28. </style>
  29.  
  30. <?php }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement