Skip to content

Instantly share code, notes, and snippets.

@macgraphic
Created January 21, 2020 10:57
  • 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
Save macgraphic/83b33799a2718993c06278a33445a7ba to your computer and use it in GitHub Desktop.
<?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 ) : ?>
<?php
global $post;
setup_postdata( $post );
?>
<div class="card cell small-12 medium-6 large-4">
<img role="img" src="<?php the_post_thumbnail_url( 'foureighty' ); ?>" alt="<?php the_title(); ?>"/>
<div class="progText">
<div class="progTitle">
<h3 class="blog-title">
<a href="<?php echo esc_html( get_permalink() ); ?>" alt="<?php the_title_attribute(); ?>">
<?php the_title(); ?>
</a>
</h3>
</div>
<div class="progExcerpt">
<h3 class="blog-title show-for-large">
<a href="<?php echo esc_html( get_permalink() ); ?>" alt="<?php the_title_attribute(); ?>">
<?php the_title(); ?>
</a>
</h3>
<?php the_excerpt(); ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment