From 0ed22b41a21ac175b35f8b7b61c96fc89703d0dc Mon Sep 17 00:00:00 2001 From: "LAPTOP-2R075DES\\HP Pavilion" Date: Mon, 26 Aug 2024 16:59:40 +0700 Subject: [PATCH] Support get term meta on the single post --- src/Traits/Archive.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Traits/Archive.php b/src/Traits/Archive.php index f782f47..8e90922 100644 --- a/src/Traits/Archive.php +++ b/src/Traits/Archive.php @@ -46,5 +46,16 @@ private function the_value() { } list( $taxonomy, $field_id ) = explode( ':', $key ); rwmb_the_value( $field_id, [ 'object_type' => 'term' ], get_queried_object_id() ); + if ( ! is_singular() ) { + return null; + } + $post_id = get_the_ID(); + $terms = get_the_terms( $post_id, $taxonomy ); + if ( empty( $terms ) ) { + return null; + } + foreach ( $terms as $term ) { + rwmb_the_value( $field_id, [ 'object_type' => 'term' ], $term->term_id ); + } } }