You need to use get_post_meta
:
get_post_meta( $post_id, $key = ”, $single = false )
Retrieve post meta field for a post
$post_id (int) (Required) Post ID.
$key (string) (Optional) The meta key to retrieve. By default, returns data for all keys. Default value: ”
$single (bool) (Optional) Whether to return a single value. Default value: false
eg.
echo get_post_meta( $post->ID, 'the-name-of-key', true);
When using true
, you will get a string
, but if you use false
instead, you will get an array
.