Snippets: Create a shortcode That Returns Post Meta (Custom Fields)

/**
 * Returns a custom field value
 * Usage [custom_field id="staff_position"]
 * Available options... staff_position, staff_twitter, staff_facebook, staff_email...etc
 * See framework/classes/metabox.php for all meta id's
 */
function my_display_custom_field( $atts ) {
	$atts = extract( shortcode_atts( array(
		'id' => '',
	), $atts ) );
	if ( ! $id ) return;
	$id   = 'wpex_'. $id; // prefix the id
	$data = get_post_meta( get_the_ID(), $id, true );
	if ( $data ) {
		return '<span class="wpex-custom-field id-'. $id .'">'. $data .'</span>';
	}
}
add_shortcode( 'custom_field', 'my_display_custom_field' );
All PHP snippets should be added via a child theme's functions.php file.