WordPress Theme Options

Theme Options

  • get_custom_header() – Appearance –> Header – must be added via add_theme_support() in functions.php
    • function themename_custom_header_setup() {
      $args = array (
      ‘default-image’ => get_template_directory_uri() . ‘img/default-image.jpg’,
      ‘default-text-color’ => ‘000’,
      ‘width’ => ‘1000’,
      ‘height’ => ‘250’,
      ‘flex-width’ => ‘true’,
      ‘flex-height’ => ‘true’,
      )
      add_theme_support( ‘custom-header’ , $args );
      }
      add_action( ‘after_setup_theme’, ‘themename_custom_header_setup’ );

      • after_setup_theme runs when a theme is activated.
      • Other Options: random-default, header-text, uploads, wp-head-callback, admin-head-callback, admin-preview-callback
    • To get the custom header in a template:
      <img alt =”” src=”php header_image(); ?>” width=”width; ?>” height=”height; ?>” />