• Skip to main content
  • Skip to primary sidebar
  • Business
  • WordPress
  • Security
  • Marketing
  • Publicity
  • Computing
  • Resources
  • Whatevs

Purely Wordpress

Just The Tech, News, and Info We Deem To Post

  • Home
  • About
  • Contact
  • Contribute
You are here: Home / Code Snippets / WordPress Category-Template.php Line 1158 Error Fix

WordPress Category-Template.php Line 1158 Error Fix

Screenshot of WordPress plugin php and html code

WordPress Category-Template.php Line 1158 Error

/**
 * Find this code snippet
 */

function get_the_terms( $post, $taxonomy ) {
	if ( ! $post = get_post( $post ) )
		return false;

	$terms = get_object_term_cache( $post->ID, $taxonomy );
	if ( false === $terms ) {
		$terms = wp_get_object_terms( $post->ID, $taxonomy );
		$to_cache = array();
		foreach ( $terms as $key => $term ) {
			$to_cache[ $key ] = $term->data;
		}
		wp_cache_add( $post->ID, $to_cache, $taxonomy . '_relationships' );
	}

	$terms = array_map( 'get_term', $terms );

Replace with this code snippet

/**
 * Replace with this code snippet
 */

function get_the_terms( $post, $taxonomy ) {
	if ( ! $post = get_post( $post ) )
		return false;

	$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' );
 		}
 	}

	if ( ! is_wp_error( $terms ) ) {
		$terms = array_map( 'get_term', $terms );
	}

by Jack Alltrade on October 17, 2016

Filed Under: Code Snippets, WordPress Core Tagged With: Bug Fix, Code

Reader Interactions

Share Your Two Cents Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Categories

  • Code Snippets
  • Development
  • File Management
  • Genesis Framework
  • Hosting
  • Legacy
  • Plugins
  • SEO
  • Tech Terms
  • Themes
  • User Experience
  • User Interface
  • WordPress Core
  • WordPress Functionality

Warning! Use at your own risk!

As always, use at your own risk and remember to backup your site prior to inserting new code.

© Copyright Jack Alltrade & Associates 2025 · Purely Supplemental™ is a trademark of Jack Alltrade & Associates