title: Fatal error: Call to a member function url() on a non-object on line 8
body: <p>I am new to PHP, currently getting error saying   </p>
  
  <blockquote>
    <p>Fatal error: Call to a member function url() on a non-object on line 8   </p>
  </blockquote>
  
  <p>Below is the code I am trying</p>
  
  <pre><code>&lt;?php
     $subpages = $site-&gt;pages()-&gt;children()-&gt;visible();
     $image_url = $subpages-&gt;image()-&gt;url();
     $title = $subpage-&gt;title()-&gt;text();
  
     foreach($subpages as $subpage) {
        echo '&lt;div class="col-md-4"&gt;';
        echo '&lt;h2&gt;' . $title . '&lt;/h2&gt;';
        echo '&lt;a href="' . $subpage-&gt;url() . '" title="' . $title . '"&gt;';
        echo '&lt;img src="' . $image_url . '" alt="' . $title . '" class="img-responsive img-thumbnail"&gt;';
        echo '&lt;/a&gt;';
        echo '&lt;/div&gt;';
     }
  ?&gt;
  </code></pre>