• Catchable fatal error: Object of class WP_Error could not be converted to string in /home/ravensne/public_html/wp-content/themes/continuum/single.php on line 120

    Please i really do need your help on correcting this error and am new to wordpress and css…

    this is d line of code, from line 117 to 123

    <?php // get parent category
                                    $category = get_the_category();
                                    $cat_tree = get_category_parents($category[0]->term_id, FALSE, ':', TRUE);
                                    $top_cat = split(':',$cat_tree);
                                    $parentObj = get_category_by_slug($top_cat[0]);
                                    $parent = $parentObj->name;
                                    ?>

    I would really appreciate your help.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter Iyke Charles

    (@iyke-charles)

    Line 120 is actually

    $top_cat = split(':',$cat_tree);

    I’d suggest checking what $cat_tree is actually returning by dumping that string to the screen.

    Thread Starter Iyke Charles

    (@iyke-charles)

    pls how do i do that…
    am new to wordpress.
    thanks

    <?php // get parent category
    $category = get_the_category();
    $cat_tree = get_category_parents($category[0]->term_id, FALSE, ':', TRUE);
    echo $cat_tree;
    /*
    $top_cat = split(':',$cat_tree);
    $parentObj = get_category_by_slug($top_cat[0]);
    $parent = $parentObj->name;
    */
    ?>
    Thread Starter Iyke Charles

    (@iyke-charles)

    it is still showing the same error…
    any other suggestion please.
    thanks

    [No bumping. If it’s that urgent, consider hiring someone.]

    What output did you get for $cat_tree?

    Thread Starter Iyke Charles

    (@iyke-charles)

    same out put…

    Catchable fatal error: Object of class WP_Error could not be converted to string in /home/ravensne/public_html/wp-content/themes/continuum/single.php on line 120

    In that case, you’re getting an error because $cat_tree is empty – which suggests that you’re trying to get the parents of a top-level category.

    Thread Starter Iyke Charles

    (@iyke-charles)

    so how do i fix it now, sorry for the disturbance.

    Well, it might help if you described what you’re using this code for and where.

    Thread Starter Iyke Charles

    (@iyke-charles)

    when i check my uploaded files via my mobile theme, there are there but when i check them via my desk to theme i get his same error either am logged in or not.
    Catchable fatal error: Object of class WP_Error could not be converted to string in /home/ravensne/public_html/wp-content/themes/continuum/single.php on line 120.

    i just want my site to work fine…

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Catchable fatal error: Object of class WP_Error could not be converted to string’ is closed to new replies.