Skip to content

Instantly share code, notes, and snippets.

@macgraphic
Last active January 21, 2020 12:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
<?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