WordPress helper: get_post_metax
<?php
/**
* @author JoseRobinson.com
* @version 1.0.0
* @link https://gist.github.com/jrobinsonc/df3b54fcc9b8f84603f30ae5dafa95d0
*/
function get_post_metax( $value, $post_id = null ) {
if (null === $post_id) {
global $post;
$post_id = $post->ID;
}
if (null === $post_id) {
return false;
}
$field = get_post_meta( $post_id, $value, true );
if (empty( $field )) {
return false;
}
return is_array( $field ) ? stripslashes_deep( $field ) : stripslashes( wp_kses_decode_entities( $field ) );
}