Skip to content

Instantly share code, notes, and snippets.

@robneu
Last active October 13, 2017 16:02
Show Gist options
  • Save robneu/6005802 to your computer and use it in GitHub Desktop.
Save robneu/6005802 to your computer and use it in GitHub Desktop.
<?php
add_action( 'genesis_entry_content', 'theme_prefix_address' );
/**
*
* Display an address using
* Genesis column classes and ACF.
*
* @author Angie Meeker
* @uses Advanced Custom Fields
*/
function theme_prefix_address() {
// Return early if not a single page
if ( ! is_single() )
return;
// Store the location data
$location_data = array(
'address_1' => get_field( 'Address_1' ),
'address_2' => get_field( 'street_address_2' ),
'po_box' => get_field( 'po_box' ),
'city' => get_field( 'city' ),
'state' => get_field( 'state' ),
'zip' => get_field( 'zip' ),
);
// Only output if we have location data
if( $location_data ) {
echo '<div class="location-wrap one-half first">';
if ( $location_data['address_1'] ) {
echo '<span>' . esc_attr( $location_data['address_1'] ) . '</span>';
}
if ( $location_data['address_2'] ) {
echo '<span>' . esc_attr( $location_data['address_2'] ) . '</span>';
}
if ( $location_data['po_box'] ) {
echo '<span>' . esc_attr( $location_data['po_box'] ) . '</span>';
}
if ( $location_data['city'] ) {
echo '<span>' . esc_attr( $location_data['city'] ) . '</span>';
}
if ( $location_data['state'] ) {
echo '<span>' . esc_attr( $location_data['state'] ) . '</span>';
}
if ( $location_data['zip'] ) {
echo '<span>' . esc_attr( $location_data['zip'] ) . '</span>';
}
echo '</div>';
}
// Store the touchpoint data
$touchpoint_data = array(
'phone' => get_field( 'phone' ),
'website' => get_field( 'website' ),
);
// Only output if we have touchpoint data
if ( $touchpoint_data ) {
echo '<div class="touchpoints-wrap one-half">';
if ( $location_data['phone'] ) {
echo '<span>' . esc_attr( $location_data['phone'] ) . '</span>';
}
if ( $location_data['website'] ) {
echo '<span>' . esc_url( $location_data['website'] ) . '</span>';
}
echo '</div>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment