If you use get_post_meta
in the template, that calls get_metadata
with meta type post
, which contains the filter get_{$meta_type}_metadata
, which in this case will be get_post_metadata
. There you can check the key and return whatever data you want.
function wpd_fake_meta( $meta_data, $object_id, $meta_key, $single ){
if( 'somekey' == $meta_key ){
return 'somefakevalue';
}
return null;
}
add_filter( 'get_post_metadata', 'wpd_fake_meta', 20, 4 );