Last active
November 9, 2018 20:44
-
-
Save mharis/2bfb5079f81ef3c94b16705f789b9e1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The template used for displaying a Hero block. | |
* | |
* @package _s | |
*/ | |
// Set up fields. | |
$title = get_field( 'title' ); | |
$text = get_field( 'text' ); | |
$button_url = get_field( 'button_url' ); | |
$button_text = get_field( 'button_text' ); | |
$background_image = get_field( 'background_image' ); | |
?> | |
<section class="hero-block"> | |
<div class="hero-content"> | |
<?php if ( $title ) : ?> | |
<h2 class="hero-title"><?php echo esc_html( $title ); ?></h2> | |
<?php endif; ?> | |
<?php if ( $text ) : ?> | |
<p class="hero-description"><?php echo esc_html( $text ); ?></p> | |
<?php endif; ?> | |
<?php if ( $button_text && $button_url ) : ?> | |
<a class="button button-hero" href="<?php echo esc_url( $button_url ); ?>"><?php echo esc_html( $button_text ); ?></a> | |
<?php endif; ?> | |
</div><!-- .hero-content--> | |
<?php if ( $background_image ) : ?> | |
<figure class="image-background" aria-hidden="true"> | |
<?php echo wp_get_attachment_image( $background_image['id'], 'full' ); ?> | |
</figure><!-- .image-background --> | |
<?php endif ?> | |
</section><!-- .hero --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment