• Resolved tuppaloprobe

    (@tuppaloprobe)


    I get this error when trying to:

    global $post;
    $categories = get_the_category($post->ID);
    $category_parrent = $categories[0]->cat_ID;
    $cat = $category_parrent;

    It is the line “$cat = $category_parrent;” which I get the error message.

    I obviously tried to Google the subject, but failed to find anything of interest.

    The problem only appears on two of my categories. Both of them, if my memory serves me right, is renamed after they where created. The rest of my categories can be written into $cat without any problem.

    Any help is greatly appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter tuppaloprobe

    (@tuppaloprobe)

    Is there really no one that can give me any answers on this issue?

    hi Tuppaloprobe – you found a resolution on this? The thread is marked as resolved. I have the same error message, also when dealing with some custom scripting dealing with categories and specifically the “get_the_category” function… I’d appreciate hearing what you found out, and see if it helps me solve my issue. Thanks!

    Thread Starter tuppaloprobe

    (@tuppaloprobe)

    The problem was not exactly in the way i described it here.

    $parentCatList = get_category_parents($cat,false,',');
    $parentCatListArray = split(",",$parentCatList);
    $topParentName = $parentCatListArray[0];
    $sdacReplace = array(" " => "-", "(" => "", ")" => "");
    $topParent = strtolower(strtr($topParentName,$sdacReplace));

    The problem here was that this line did not get any data, or parameter.
    $parentCatListArray = split(",",$parentCatList);

    The $cat here did not have any value because of an slug typo on one post and thus no value here and the spit thing on the previous line did not get a value and it seems that thats what the error message means or at least what it meant in this case.
    $parentCatList = get_category_parents($cat,false,',');

    I hope this helps you.

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