Catchable fatal error: Object of class WP_Error – pluggable.php
-
Hi folks – I get the following error on my *top-level* category archive:
Catchable fatal error: Object of class WP_Error could not be converted to string in /home/username/example.com/wp-includes/pluggable.php on line 882
I understand that reference to the pluggable.php file likely means some conflict / issue with a plugin. However, I only have on plugin installed and activated – “WP No Category Base”, which “Removes ‘/category’ from your category permalinks”. The error still occurs when that plugin is deactivated.
I actually find that the conflict seems to be caused, in part, by some custom code in my category.php template. As noted, the code is *meant* to redirect the top-level category to the first child category.
Code:
<?php // redirect top-level to first child $thiscategory = get_query_var('cat'); $cat_query = array ( 'child_of' => $thiscategory, 'orderby' => 'id', 'order' => 'desc' ); $catkids = get_categories($cat_query); if ($catkids) { $firstchild = $catkids[0]; wp_redirect(get_category_link($firstchild->term_id)); } ?>
When I remove that code, no more error.
Can anybody help me identify what in that code is causing the error, and even better, how to rewrite it to avoid the error? Thanks in advance for any suggestions and assistance.
- The topic ‘Catchable fatal error: Object of class WP_Error – pluggable.php’ is closed to new replies.