WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My php_error.log in my console (locally on OSX) is reporting 3 PHP Notices. The PHP Notices only appear when browsing each admin page in the back-end for a site (running multisite) that uses a child theme. The child theme uses the parent theme's sidebar.php which the code below is placed in.

The PHP notices do not show for the site that uses the actual parent theme. Also, if I make another sidebar.php in the child theme, then the notices are still present. Interestingly, these notices do not appear when browsing the site locally, and everything works as expected. They only appear when browsing around the admin. The code in my sidebar is the exact code from this page on the WP Codex.

The exact code is:

 if($post->post_parent) {
 $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
 $titlenamer = get_the_title($post->post_parent);

else {
 $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
 $titlenamer = get_the_title($post->ID);

if ($children) { ?>

<h2> <?php echo $titlenamer; ?> </h2>
  <?php echo $children; ?>

<?php } ?>

Any the PHP notices are:

PHP Notice:  Trying to get property of non-object in sidebar.php on line 10
PHP Notice:  Trying to get property of non-object in sidebar.php on line 16
PHP Notice:  Trying to get property of non-object in sidebar.php on line 17

The lines in question from the above code are:

if($post->post_parent) { // line 10
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); // line 16
$titlenamer = get_the_title($post->ID); // line 17

Any ideas why these notices would be appearing in the admin pages and only for the child theme? Should I just ignore them?

share|improve this question
up vote 2 down vote accepted

That's pretty simple:

You're trying to get the parent property from the $post object, but that is either NULL or simply not attached. In both cases, you are

Trying to get property of non-object

from the $post object.

Simply check if ( isset( $post->parent ) ) { /* do stuff */ }.

share|improve this answer
Thanks, an oldie but still good to know how to fix :) – Andrew Oct 9 '12 at 22:50

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.