Created
December 12, 2015 01:21
-
-
Save neilgee/6933d47d2bec2351456b to your computer and use it in GitHub Desktop.
Fix Category Template get_the_terms error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //<~ don't add in the opening php | |
//replace the existing function on line 1144 with the below | |
//source - https://core.trac.wordpress.org/ticket/34723 | |
function get_the_terms( $post, $taxonomy ) { | |
$terms = get_object_term_cache( $post->ID, $taxonomy ); | |
if ( false === $terms ) { | |
$terms = wp_get_object_terms( $post->ID, $taxonomy ); | |
if ( ! is_wp_error( $terms ) ) { | |
$to_cache = array(); | |
foreach ( $terms as $key => $term ) { | |
$to_cache[ $key ] = $term->data; | |
} | |
wp_cache_add( $post->ID, $to_cache, $taxonomy . '_relationships' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment