Reputation: 33
I am new to wordpress. i am facing problem to understand codes written in twenty fourteen theme in wordpress . In staring of body of header.php there is some piece of code which i am not able to understand, like what they do
<?php if ( get_header_image() ) : ?>
<div id="site-header">
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
<img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>">
</a>
</div>
<?php endif; ?>
please someone help me to understand what this piece of code do
Upvotes: 0
Views: 219
Reputation: 415
<?php if ( get_header_image() ) : ?>
It is for if you set a Banner Image for you theme you can change by Customize theme and change or remove as shown in Image below through Admin Panel go to Appearance > customize then it will lead you to the page of customization as shown in Image there you will find Header Image.
<div id="site-header">
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
<img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>">
</a>
</div>
so Here in this code If the header Image found it will set in the <img>
automatically it's alt
will be set as site NAME and height or width will be set as theme defauld CSS. and the <a>
before <img>
is for leading link for HOME PAGE.
Upvotes: 2