Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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="details">Details</div>';
- echo '<div class="location-wrap one-half first">';
- if ( $location_data['address_1'] ) {
- echo '<div class="location">' . esc_attr( $location_data['address_1'] ) . '</div>';
- }
- if ( $location_data['address_2'] ) {
- echo '<div class="location">' . esc_attr( $location_data['address_2'] ) . '</div>';
- }
- if ( $location_data['po_box'] ) {
- echo '<div class="location">' . esc_attr( $location_data['po_box'] ) . '</div>';
- }
- 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 ( $touchpoint_data['phone'] ) {
- echo '<div class="touchpoint">' . esc_attr( $touchpoint_data['phone'] ) . '</div>';
- }
- if ( $touchpoint_data['website'] ) {
- echo '<div class="touchpoint">' . esc_url( $touchpoint_data['website'] ) . '</div>';
- }
- echo '</div>';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement