/New Programme Block Secret
Last active
January 21, 2020 12:36
Star
You must be signed in to star a gist
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 | |
/** | |
* Programmes Block Template. | |
* | |
* @param array $block The block settings and attributes. | |
* @param string $content The block inner HTML (empty). | |
* @param bool $is_preview True during AJAX preview. | |
* @param (int|string) $post_id The post ID this block is saved to. | |
*/ | |
// Create id attribute allowing for custom "anchor" value. | |
$id = 'prog-' . $block['id']; | |
if ( ! empty( $block['anchor'] ) ) { | |
$id = $block['anchor']; | |
} | |
// Create class attribute allowing for custom "class_name" and "align" values. | |
$class_name = 'progBlock'; | |
if ( ! empty( $block['class_name'] ) ) { | |
$class_name .= ' ' . $block['class_name']; | |
} | |
if ( ! empty( $block['align'] ) ) { | |
$class_name .= ' align' . $block['align']; | |
} | |
if ( $is_preview ) { | |
$class_name .= ' is-admin'; | |
} | |
?> | |
<div id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( $class_name ); ?>"> | |
<?php | |
$posts = get_field( 'progs' ); | |
if ( $posts ) : | |
?> | |
<div class="progGrid grid-x grid-margin-x grid-margin-y"> | |
<?php foreach ( $posts as $post ) : ?> | |
<div class="card cell small-12 medium-6 large-4"> | |
<img role="img" src="<?php echo esc_url( get_the_post_thumbnail_url( $post , 'foureighty' ) ); ?>" alt="<?php echo get_the_title( $post ); ?>"/> | |
<div class="progText"> | |
<div class="progTitle"> | |
<h3 class="blog-title"> | |
<a href="<?php echo esc_html( get_permalink( $post ) ); ?>" alt="<?php the_title_attribute( [ 'post' => $post ] ); ?>"> | |
<?php echo get_the_title( $post ); ?> | |
</a> | |
</h3> | |
</div> | |
<div class="progExcerpt"> | |
<h3 class="blog-title show-for-large"> | |
<a href="<?php echo esc_html( get_permalink( $post ) ); ?>" alt="<?php the_title_attribute( [ 'post' => $post ] ); ?>"> | |
<?php echo get_the_title( $post ); ?> | |
</a> | |
</h3> | |
<?php echo the_excerpt( $post ); ?> | |
</div> | |
</div> | |
</div> | |
<?php endforeach; ?> | |
</div> | |
<?php endif; ?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment