Skip to content

Commit

Permalink
Support get term meta on the single post
Browse files Browse the repository at this point in the history
  • Loading branch information
lexuanbao161096 authored and rilwis committed Sep 11, 2024
1 parent 6cbe8d5 commit 0ed22b4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Traits/Archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
}

0 comments on commit 0ed22b4

Please sign in to comment.