Skip to content

Instantly share code, notes, and snippets.

@bph
Created May 17, 2019 20:08
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 bph/cd2ba141ac8732107d51d08a9046bd0d to your computer and use it in GitHub Desktop.
Save bph/cd2ba141ac8732107d51d08a9046bd0d to your computer and use it in GitHub Desktop.
Example code for ACF building blocks
<?php
// 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>
<br/>
<span class="team-membe-extension"><?php echo $extension; ?></span><br/>
<span class="team-membe-email-address"><?php echo $email_address; ?>
</span>
</blockquote>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment