title: How can I resolve undefined variable and trying to get property of non-object in errors?
body: <p>When my test site has debugging set to false, all is well. When I go to debug my templates, I'm seeing the following errors:</p>
  
  <pre><code>Notice: Undefined variable: post in /home/xxxxxxx/public_html/wp-content/themes/twentyeleven-child/functions.php on line 15
  
  Notice: Trying to get property of non-object in /home/xxxxxxxx/public_html/wp-content/themes/twentyeleven-child/functions.php on line 15
  </code></pre>
  
  <p>Here is my code but I can't tell what the variable is or the property of the non-object.</p>
  
  <pre><code>function excerpt($num) {
   $limit = $num+1;
   $excerpt = explode(' ', get_the_excerpt(), $limit);
   array_pop($excerpt);
   $excerpt = implode(" ",$excerpt)."... (&lt;a href='" .get_permalink($post-&gt;ID) ." '&gt;Read more&lt;/a&gt;)";
   echo $excerpt;
  }
  </code></pre>
  
  <p>This is the loop I'm using in my template:</p>
  
  <pre><code>&lt;?php $postslist = get_posts('category=4&amp;numberposts=3&amp;order=DESC&amp;orderby=post_date');
  foreach ($postslist as $post) :
  setup_postdata($post); ?&gt;
  &lt;div class="post_item"&gt;
  &lt;span class='side_date'&gt;&lt;?php the_time('F j, Y'); ?&gt;&lt;/span&gt;&lt;br /&gt;
  &lt;h2&gt;&lt;a href="&lt;?php the_permalink() ?&gt;" rel="bookmark"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;
  &lt;?php excerpt(11); ?&gt;&lt;/div&gt;
  &lt;?php endforeach; ?&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Thanks...</p>