fix: reuse CHRNX term caches
This commit is contained in:
2 files changed
+48
-2
No files matched your search
+6
-2
@@ -153,8 +153,12 @@ function chrnx_get_eligible_editorial_post_ids( $extra_args = array() ) {
|
||||
* @return string Topic slug or empty string.
|
||||
*/
|
||||
function chrnx_get_post_topic_slug( $post_id ) {
|
||||
$terms = wp_get_object_terms( $post_id, 'chrnx_topic', array( 'fields' => 'slugs' ) );
|
||||
return ! is_wp_error( $terms ) && ! empty( $terms ) ? (string) reset( $terms ) : '';
|
||||
$terms = get_the_terms( $post_id, 'chrnx_topic' );
|
||||
if ( is_wp_error( $terms ) || empty( $terms ) ) {
|
||||
return '';
|
||||
}
|
||||
$term = reset( $terms );
|
||||
return $term instanceof WP_Term ? (string) $term->slug : '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user