Implementing a custom header via php
-
Daer community, I am very new to WP and am currently learning to build customized websites via WP. Right now, I am struggling with implementing a custom header showing a movie (using the “understrap“-theme).
I first installed the “understrap“-theme and then the “understrap-child“-theme an activated the latter one. Regarding to “https://codex.ww.wp.xz.cn/Custom_Headers”, I added the following lines to “understrap-child/functions.php”:— edits to “functions.php” in “understrap-child/functions.php”/start—
register_default_headers( $headers ); $defaults = array( 'default-image' => get_template_directory_uri() . '/images/header.jpg', 'width' => 300, 'height' => 200, 'flex-height' => false, 'flex-width' => false, 'uploads' => true, 'random-default' => false, 'header-text' => true, 'default-text-color' => '', 'wp-head-callback' => '', 'admin-head-callback' => '', 'admin-preview-callback' => '', ); add_theme_support( 'custom-header', $defaults );—-edits to “functions.php” in “understrap-child/functions.php”/end————-
After reloading my WP-site, under “Appearance/customize” the “Header Image” option showed up and I uploaded a respective image. Then, I copied the “header.php” from “/understrap” to “/understrap-child” and added after “</nav><!– .site-navigation –>”:
—— edits to “header.php” in “understrap-child/functions.php”/start————-
<img src="<?php header_image(); ?>" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="" />
——– edits to “header.php” in “understrap-child/functions.php”/end———… the header image shows up, but I cant change the width when changing the width from 300 to exp. 800. Then, regarding to “https://developer.ww.wp.xz.cn/themes/functionality/custom-headers/”, I added the following lines to “understrap-child/functions.php”:
——- additions to “functions.php” in “understrap-child/functions.php”/start——
function understrap_custom_header_setup() { $defaults = array( // Default Header Image to display 'default-image' => get_template_directory_uri() . '/images/headers/default.jpg', // Display the header text along with the image 'header-text' => false, // Header text color default 'default-text-color' => '000', // Header image width (in pixels) 'width' => 1000, // Header image height (in pixels) 'height' => 198, // Header image random rotation default 'random-default' => false, // Enable upload of image file in admin 'uploads' => false, // function to be called in theme head section 'wp-head-callback' => 'wphead_cb', // function to be called in preview page head section 'admin-head-callback' => 'adminhead_cb', // function to produce preview markup in the admin screen 'admin-preview-callback' => 'adminpreview_cb', ); } add_action( 'after_setup_theme', 'understrap_custom_header_setup' );—- additions to “functions.php” in “understrap-child/functions.php”/end——-
This didn’t have any effects on the width of the image either. I think, my very basic problem is that I am not experienced with WPs php-framework… but I am willing to learn…. maybe someone could help me with this??? Thx a lot!
The topic ‘Implementing a custom header via php’ is closed to new replies.