Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to use the $post object from functions.php in my theme however if I attempt to var_dump($post) it returns NULL.

Here is my code:

function breadcrumb_navigation() {
    $page = $post;
    $parents = array();
    while ($page->post_parent){
        array_push($parents, $page);
        $page = $page->post_parent;
    if (sizeof($parents) > 0) {
        foreach($parents as $parent) {
            echo '<li><a href="'.get_permalink($parent->ID).'">'.$parent->post_title.'</a><ul class="child">', wp_list_pages(array('child_of' => $post->post_parent,'exclude' => $post->ID)), '</ul></li>';

Can anyone tell why this would be happening?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Call in global $post; at the top of the function.

share|improve this answer
That was simple :P – George Reith Apr 13 '12 at 15:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.