From 5bd8d9b910220e3f7c790f045a5d4e1face2f534 Mon Sep 17 00:00:00 2001 From: Robin Cornett Date: Fri, 20 Jan 2017 16:52:10 -0500 Subject: [PATCH] Update taxonomy list in helper function For some reason, this works until 4.8 (currently alpha), at which point it always returns an empty array for the terms list. --- includes/helper-functions.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/includes/helper-functions.php b/includes/helper-functions.php index 724b2c0..12c4872 100644 --- a/includes/helper-functions.php +++ b/includes/helper-functions.php @@ -31,15 +31,20 @@ function displayfeaturedimagegenesis_get_term_image( $term_id, $image_id = '' ) /** * gets the term image ID - * @return image_id reusable function to get a post's term image, if it exists + * @return int reusable function to get a post's term image, if it exists * + * @param $image_id string * @since 2.1.0 */ function display_featured_image_genesis_get_term_image_id( $image_id = '' ) { - $taxonomies = get_taxonomies(); - $args = array( 'orderby' => 'count', 'order' => 'DESC' ); - $terms = wp_get_object_terms( get_the_ID(), $taxonomies, $args ); + $post = get_post( get_the_ID() ); + $taxonomies = array(); + foreach ( get_object_taxonomies( $post, 'names' ) as $taxonomy ) { + $taxonomies[] = $taxonomy; + } + $args = array( 'orderby' => 'count', 'order' => 'DESC' ); + $terms = wp_get_object_terms( get_the_ID(), $taxonomies, $args ); foreach ( $terms as $term ) { $term_id = $term->term_id;