title: Wordpress: Notice: Object of class WP_Post could not be converted to int on homepage
body: <p>I am working on a custom login page plugin, and the plugin works as expected. However, when I navigate to my home page, I get an error</p>
  
  <blockquote>
    <p>Notice: Object of class WP_Post could not be converted to int in C:\MAMP\htdocs\wp-includes\general-template.php on line 1018</p>
  </blockquote>
  
  <p>After I comment out parts of the code, I find out the <code>foreach</code> loop cause the problem. Need a solution.</p>
  
  <pre><code>// Set shortcode Tag
  $login_shortcode = 'custom_login_form';
  
  
  // Retrieve Login Page ID
  $page_id = ! empty( $page_id ) ? $page_id : '';
  $pages_args = array(
      'post_type' =&gt; 'page'
  );
  $pages = get_pages( $pages_args );
  foreach ( $pages as $page ) {
      if ( ( $page-&gt;post_title == 'Login' &amp;&amp; strpos( $page-&gt;post_content, $login_shortcode ) ) &amp;&amp; $page-&gt;post_status == 'publish' ) {
          $page_id = $page-&gt;ID;
      }
  }
  </code></pre>