Support » How-To and Troubleshooting » Catchable fatal error: Object of class WP_Error – pluggable.php

Catchable fatal error: Object of class WP_Error – pluggable.php

  • luispunchy


    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.


    <?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];

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • luispunchy


    OK – just going to update this as I work through it, in hopes that maybe the additional info will help my eventual savior actually find a solution 😉

    So the problem in that whole block of code has been isolated to the last line:
    wp_redirect(get_category_link($firstchild->term_id)); — comment that out, and the error goes away. Of course, I don’t get the desired result – that is the redirect doesn’t work, but the code ceases to throw an error… so, I suspect I’m on the trail of the bug.

    My first thought was maybe wp_redirect itself was the problem – reading the codex on that function, seems it can only be used once. So maybe it is being used elsewhere. However, my only guess for *where* else ‘wp_redirect’ is being uses is the “WP No Category Base” plugin and again this error still occurs when the plugin is disabled.)

    Nonetheless, I tried a different redirection method. Replacing that wp_redirect line with the following:

    $URI = get_category_link($firstchild->term_id);
    // redirect
    header('Location: '.$URI);

    Still get the error, only now instead of referencing the pluggable.php core file, it references my category.php template (where this suspect code lives…) – so, again, I’m on the trail of the bug…

    Sorry for the long-winded play-by-play… just hoping a kind and curious forum member can help.

    Am I using get_category_link incorrectly? Any alternatives?

    I have the same problem.

    Does any one solve this problem? Please share to us

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Catchable fatal error: Object of class WP_Error – pluggable.php’ is closed to new replies.