Skip to content

Instantly share code, notes, and snippets.

@nirbhay18
Created November 20, 2020 17:50
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 nirbhay18/f437bfdfc209a17e29b7965f1801df23 to your computer and use it in GitHub Desktop.
Save nirbhay18/f437bfdfc209a17e29b7965f1801df23 to your computer and use it in GitHub Desktop.
Shortcode to Fetch data from ACF Pro Google Map Field
add_shortcode( 'pp_map' , function( $atts ) {
if (!function_exists('get_field') ) return '';
$atts = shortcode_atts( array( 'field' => false , 'sub' => 'address' ) , $atts, $shortcode = 'pp_map' );
if ($atts[ 'field' ] && $map = get_field( $atts[ 'field'] ) ) {
if ( isset( $map[ $atts['sub'] ] ) ) return $map[ $atts['sub'] ];
}
return '[ something went wrong ]';
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment