Advertisement
firoze

wordpress header & theme background changing

Dec 26th, 2014
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.29 KB | None | 0 0
  1.  
  2.  
  3.  
  4. // Header images dynamic & changing
  5.  
  6. <!------------------------------------------------------------------->
  7. // functions.php
  8.  
  9. $args = array(
  10.     'default-color'         => 'fff',
  11.     'default-image' => get_template_directory_uri() . '/images/custom-header.jpg',
  12.     'wp-head-callback'          => '_custom_background_cb',
  13.     'admin-head-callback'       => '',
  14.     'admin-preview-callback'    => '',
  15.     'random-default'         => false,
  16.     'width'                  => 0,
  17.     'height'                 => 0,
  18.     'flex-height'            => false,
  19.     'flex-width'             => false,
  20.     'default-text-color'     => '',
  21.     'header-text'            => true,
  22.     'uploads'                => true,
  23. );
  24. add_theme_support( 'custom-header', $args );
  25.  
  26. <!------------------------------------------------------------------->
  27.  
  28.  
  29. <!------------------------------------------------------------------------>
  30. // header.php
  31.  
  32. <?php
  33.         $header_image = get_header_image();
  34.         if ( ! empty( $header_image ) ) { ?>
  35.             <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" rel="home">
  36.                 <img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="<?php echo get_bloginfo( 'name' ); ?>" />
  37.             </a>
  38.         <?php } // if ( ! empty( $header_image ) )
  39. ?>
  40. <!------------------------------------------------------------------------>
  41.  
  42.  
  43.  
  44. // Background change
  45. // make sure that body{background:url(../images/bg.png) repeat fixed 0 0;}  you did not use background in body in css
  46.  
  47. show your body like this   <body  <?php body_class(); ?>>
  48.  
  49.  
  50. // functions.php
  51.  
  52. $defaults = array(
  53.     'default-color'         => 'fff',
  54.     'default-image'         => get_template_directory_uri() . '/images/bg.png) repeat fixed 0 0;',
  55.     'wp-head-callback'          => '_custom_background_cb',
  56.     'admin-head-callback'       => '',
  57.     'admin-preview-callback'    => '',
  58.     'random-default'         => false,
  59.     'width'                  => 0,
  60.     'height'                 => 0,
  61.     'flex-height'            => false,
  62.     'flex-width'             => false,
  63.     'default-text-color'     => '',
  64.     'header-text'            => true,
  65.     'uploads'                => true,
  66. );
  67.  
  68. add_theme_support( 'custom-background', $defaults);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement