Created
December 17, 2015 14:56
-
-
Save sectsect/34ae7c97ac297c9bf15c to your computer and use it in GitHub Desktop.
Fix bug "get_the_terms" on wordpress 4.4. you can add the patch yourself to the category-template.php in the wp-includes directory replacing the get_the_terms function.
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 | |
function get_the_terms( $post, $taxonomy ) { | |
if ( ! $post = get_post( $post ) ) | |
return false; | |
$terms = get_object_term_cache( $post->ID, $taxonomy ); | |
if(false === $terms || empty($terms)){ | |
$terms = wp_get_post_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