Skip to content

Commit 07a63b2

Browse files
committed
Use get_the_terms when possible to retrieve post's terms
1 parent d2c8783 commit 07a63b2

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

classes/Models/Model.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,11 @@ public function set_terms( $terms, string $taxonomy, $append = false ) {
214214
* @return \WP_Term[]|\WP_Error
215215
*/
216216
public function get_terms( string $taxonomy, array $args = [] ) {
217-
$terms = get_object_term_cache( $this->get_id(), $taxonomy );
218-
if ( false === $terms ) {
219-
$terms = wp_get_object_terms( $this->get_id(), $taxonomy, $args );
217+
if ( empty( $args ) ) {
218+
return get_the_terms( $this->get_id(), $taxonomy );
220219
}
221220

222-
return $terms;
221+
return wp_get_object_terms( $this->get_id(), $taxonomy, $args );
223222
}
224223

225224
/**

0 commit comments

Comments
 (0)