Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example code for ACF building blocks
// create id attribute for specific styling
$id = 'team-member' . $block['id'];
// create align class ("alignwide") from block setting ("wide")
$align_class = $block['align'] ? 'align' . $block['align'] : '';
// Load values and asigning defaults for the block fields.
$short_bio = get_field('short_bio') ?: 'the short bio goes here... ';
$first_name = get_field('first_name') ?: 'First Name';
$last_name = get_field('last_name') ?: 'Last Name';
$image = get_field('picture');
$email_address = get_field('email_address');
$extension = get_field('extension');
<div id="<?php echo $id; ?>" class="team-member <?php echo $align_class; ?>">
<h2><?php echo $first_name; ?> <?php echo $last_name; ?></h2>
<blockquote class="team-member-blockquote">
<img class="teamphoto" src="<?php echo $image['url']; ?>" alt="" alt="<?php echo $first_name ?> <?php echo $last_name?> " width="150" style="float:left;padding:4px;margin;2px;"/>
<span class="team-member-short-bio"><?php echo $short_bio; ?></span>
<span class="team-membe-extension"><?php echo $extension; ?></span><br/>
<span class="team-membe-email-address"><?php echo $email_address; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment