• Using the theme with PHP5.3 and > sometimes you get the error:

    PHP Catchable fatal error:  Object of class WP_Error could not be converted to string in xxxxx\wp-content\themes\themolio\functions.php on line 365

    This is because the call to get_category_parents should expect a text OR A WP ERROR object!
    There are many calls in themolio of this function that assume the return be a text, so I solved modifying wordpress:
    wp-includes\category-template.php – line 42:

    function get_category_parents( $id, $link = false, $separator = '/', $nicename = false, $visited = array() ) {
    	$chain = '';
    	$parent = get_term( $id, 'category' );
    	if ( is_wp_error( $parent ) )
    		return ""; //if $parent ERROR!! PHP v5.4.7 generate a "PHP Catchable fatal error:  Object of class WP_Error could not be converted to string"
    (....)
    }

Viewing 1 replies (of 1 total)
  • Thread Starter faina09

    (@faina09)

    better fix:
    on \themolio\functions.php replacede the 3 calls to get_category_parents with a call to this function:

    /* fixes: PHP Catchable fatal error:  Object of class WP_Error could not be converted to string */
    function themolio_get_category_parents( $id, $link = false, $separator = '/', $nicename = false, $visited = array() ) {
    	$ct = get_category_parents( $id, $link, $separator, $nicename, $visited );
    	if ( is_wp_error( $ct ) )
    		return "";
    	else
    		return $ct;
    }

Viewing 1 replies (of 1 total)
  • The topic ‘PHP Catchable fatal error using get_category_parents’ is closed to new replies.