• missmoxie

    (@missmoxie)


    Today I upgraded a client to 3.1 from 3.04. She’s running multi-site. The functions.php file contains a section that is using get_ancestors and the entire site, including the dashboard gives me the double-bird now and won’t load. I have no clue what to change to make it that function work again. When I comment out that portion, the dashboard reloads and the site does, too, except obviously with errors in the header call.

    Do you have any bright ideas? ?? I’m desperate to get her site back online and have had very, very little luck finding anything in Google or these forums. A few other things *kind of* like this, but with no resolutions.

    This is the error I receive:
    Fatal error: Cannot redeclare get_ancestors() (previously declared in /home/account_name/public_html/wp-includes/taxonomy.php:3055) in /home/account_name/public_html/wp-content/themes/account_name/functions.php on line 153

    And this is the snippet it’s referring to:

    function get_ancestors ($p) {
        $parent = $p->post_parent;
        $ancestors = array ();
        while ($parent != '0') {
    		if ($parent) {
    			$ancestors[] = $parent;
    		}
            $p = get_post ($parent);
            $parent = $p->post_parent;
        }
        return $ancestors;
    }

    I tried changing get_ancestors to get_post_ancestors, but it broke again and I wasn’t sure what to do. I think something to do with wp-includes/post.php, but this is just a little beyond my scope.

    I’d appreciate any insight. Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter missmoxie

    (@missmoxie)

    Naturally, as SOON as I hit post, the answer is discovered and it’s all fixed now.

    From my friend:

    it looks like get_ancestors() in this case is a custom function in the functions file; however a core function called get_ancestors() was introduced with WP 3.1, so it looks like you’re getting a conflict there. The custom function is only expecting a single parameter (as a post, it looks like), whereas the core get_ancestors() expects two object parameters:

    https://codex.www.ads-software.com/Function_Reference/get_ancestors

    Probably the easiest thing to do would be to rename the custom function to something like get_my_ancestors(), and amend any calls to it.

    So I did that and all seems to be well. ??

    Thanks – I renamed that same function, and worked for me.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get_ancestors issue – can see where to fix, just not WHAT to fix’ is closed to new replies.