/** * Shortcode to display meta value * * @param array $atts Shortcode attributes, same as meta() function, but has more "meta_key" parameter * * @see meta() function below * * @return string */ function rwmb_meta_shortcode($atts) { $atts = wp_parse_args($atts, array('post_id' => get_the_ID())); if (empty($atts['meta_key'])) { return ''; } $field_id = $atts['meta_key']; $post_id = $atts['post_id']; unset($atts['meta_key'], $atts['post_id']); return rwmb_the_field($field_id, $atts, $post_id, false); }
/** * Get post meta. * * @param string $key Meta key. Required. * @param int|null $post_id Post ID. null for current post. Optional * @param array $args Array of arguments. Optional. * @return mixed */ static function meta($key, $args = array(), $post_id = null) { $args = wp_parse_args($args, array('type' => 'text')); $meta = in_array($args['type'], array('oembed', 'map')) ? rwmb_the_field($key, $args, $post_id, false) : rwmb_get_field($key, $args, $post_id); return apply_filters('rwmb_meta', $meta, $key, $args, $post_id); }