Advertisement
AMEEKER

Genesis, Custom Fields, Hook, Two Columns, Div Class surroun

Jul 16th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. add_action( 'genesis_entry_content', 'theme_prefix_address' );
  2. /**
  3. *
  4. * Display an address using
  5. * Genesis column classes and ACF.
  6. *
  7. * @author Angie Meeker
  8. * @uses Advanced Custom Fields
  9. */
  10.  
  11. function theme_prefix_address() {
  12. // Return early if not a single page
  13. if ( !is_single() )
  14. return;
  15.  
  16. // Store the location data
  17. $location_data = array(
  18. 'address_1' => get_field( 'Address_1' ),
  19. 'address_2' => get_field( 'street_address_2' ),
  20. 'po_box' => get_field( 'po_box' ),
  21. 'city' => get_field( 'city' ),
  22. 'state' => get_field( 'state' ),
  23. 'zip' => get_field( 'zip' ),
  24. );
  25.  
  26. // Only output if we have location data
  27. if( $location_data ) {
  28. echo '<div class="details">Details</div>';
  29. echo '<div class="location-wrap one-half first">';
  30. if ( $location_data['address_1'] ) {
  31. echo '<div class="location">' . esc_attr( $location_data['address_1'] ) . '</div>';
  32. }
  33. if ( $location_data['address_2'] ) {
  34. echo '<div class="location">' . esc_attr( $location_data['address_2'] ) . '</div>';
  35. }
  36. if ( $location_data['po_box'] ) {
  37. echo '<div class="location">' . esc_attr( $location_data['po_box'] ) . '</div>';
  38. }
  39. if ( $location_data['city'] ) {
  40. echo '<span>' . esc_attr( $location_data['city'] ) . '</span>';
  41. }
  42. if ( $location_data['state'] ) {
  43. echo '<span>, ' . esc_attr( $location_data['state'] ) . '</span>';
  44. }
  45. if ( $location_data['zip'] ) {
  46. echo '<span> ' . esc_attr( $location_data['zip'] ) . '</span>';
  47. }
  48. echo '</div>';
  49. }
  50.  
  51. // Store the touchpoint data
  52. $touchpoint_data = array(
  53. 'phone' => get_field( 'phone' ),
  54. 'website' => get_field( 'website' ),
  55. );
  56.  
  57. // Only output if we have touchpoint data
  58. if ( $touchpoint_data ) {
  59. echo '<div class="touchpoints-wrap one-half">';
  60. if ( $touchpoint_data['phone'] ) {
  61. echo '<div class="touchpoint">' . esc_attr( $touchpoint_data['phone'] ) . '</div>';
  62. }
  63. if ( $touchpoint_data['website'] ) {
  64. echo '<div class="touchpoint">' . esc_url( $touchpoint_data['website'] ) . '</div>';
  65. }
  66. echo '</div>';
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement