Skip to content

Instantly share code, notes, and snippets.

@macgraphic
Last active October 30, 2019 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macgraphic/5458460acbccca46eb1a87910a1b29e3 to your computer and use it in GitHub Desktop.
Save macgraphic/5458460acbccca46eb1a87910a1b29e3 to your computer and use it in GitHub Desktop.
<?php
/**
* Gold Sponsors 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 = 'sponsgold-' . $block['id'];
if ( ! empty( $block['anchor'] ) ) {
$id = $block['anchor'];
}
// Create class attribute allowing for custom "class_name" and "align" values.
$class_name = 'spons-gold-contain';
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 ); ?> grid-x">
<!-- Gold Sponsors LIST -->
<?php
query_posts( array(
'post_type' => 'supporters',
'supporter_level' => 'gold',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC',
) );
if ( have_posts() ) :
while ( have_posts() ) :
the_post();
?>
<div class="cell small-6 medium-4 large-3 gold-supporter align-self-middle align-center">
<?php
$link = get_field( 'supporterlink', get_the_id() );
if ( $link ) : ?>
<a href="<?php echo esc_url( $link ); ?>">
<?php endif; ?>
<img role="img" src="<?php the_post_thumbnail_url( 'medium' ); ?>" alt="<?php the_title(); ?>"/>
<?php if ( $link ) : ?>
</a>
<?php endif; ?>
</div>
<?php
endwhile;
endif;
wp_reset_query();
?>
<!-- END Gold Sponsors LIST -->
</div>
<?php
wp_reset_postdata();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment