WordPress.org

Support

Support » How-To and Troubleshooting » Catchable fatal error: Object of class WP_Error could not be converted to string

Catchable fatal error: Object of class WP_Error could not be converted to string

  • 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)
  • Line 120 is actually

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

    @esmi

    Forum Moderator

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

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

    esmi

    @esmi

    Forum Moderator

    <?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;
    */
    ?>

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

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

    esmi

    @esmi

    Forum Moderator

    What output did you get for $cat_tree?

    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

    esmi

    @esmi

    Forum Moderator

    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.

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

    esmi

    @esmi

    Forum Moderator

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

    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.
Skip to toolbar