Try to get custom field data in a simple plugin. added the code. but does not work

function related_posts ($ atts) {

// set the category ID (or more category IDs)
// you want to ignore in the following table
$ cats_to_ignore = array (2);
$ categories = wp_get_post_categories (get_the_ID ());
$ category_in = array_diff ($ categories, $ cats_to_ignore);
// ignore only if we still have a category after ignoring
if (count ($ category_in) == 0) {
$ category_in = $ categories;
}
$ cat_args = array (
& # 39; category__in & # 39; => $ category_in,
& # 39; posts_per_page & # 39; => 5,
& # 39; orderby & # 39; => & # 39; date,
& # 39; post__not_in & # 39; => array (get_the_ID ())
)
$ cat_query = new WP_Query ($ cat_args);
while ($ cat_query-> have_posts ()): $ cat_query-> the_post ();
/ * just an example of markup for related articles * /
echo & # 39;
  • & # 39 ;. get_the_title (). & # 39;
  • & # 39 ;; $ gread = get_post_meta ($ post-> ID, & quot; read_time & # 39 ;, true); $ gdate = get_the_date (); echo & # 39; Read the time: & # 39; $ Gread. & # 39; Minutes & # 39 ;; echo & # 39; Posted: & # 39; $ Gdate. & # 39; & # 39 ;; waiting; // reset $ post after the end of the custom loop

    }
    add_shortcode (& # 39; relatedpost & # 39 ;, & quot; related_posts & quot;);