{"id":3476723,"date":"2013-02-16T20:31:57","date_gmt":"2013-02-16T20:31:57","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/invalid-argument-supplied-for-foreach-11\/"},"modified":"2016-08-20T21:42:30","modified_gmt":"2016-08-20T21:42:30","slug":"invalid-argument-supplied-for-foreach-11","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/invalid-argument-supplied-for-foreach-11\/","title":{"rendered":"Invalid argument supplied for foreach()"},"content":{"rendered":"<p>I&#8217;ve written a simple plugin to add a couple of post types to my multisite installation. One of the post types has a meta field which contains a drop down list of posts from the other post type. However I&#8217;m getting the following error;<\/p>\n<p><code>Invalid argument supplied for foreach() in blaa\\wp-includes\\query.php on line 1702<\/code><\/p>\n<p>My code to populate the dropdown is as follows;<\/p>\n<pre><code>$properties = get_posts( array( &#039;post_type&#039; =&gt; &#039;property&#039;, &#039;posts_per_page&#039; =&gt; -1 ) );\n$propertyList = array();\n\nif( $properties ) {\n\tforeach( $properties as $property ) {\n\t\t$propertyList[] = array(\n\t\t\t&#039;id&#039; =&gt; $property-&gt;ID,\n\t\t\t&#039;name&#039; =&gt; $property-&gt;post_title\n\t\t);\n\t}\n}<\/code><\/pre>\n<p>I&#8217;ve been looking and trying to fix this for a couple of hours now but I&#8217;m beaten. Has anyone any suggestions?<\/p>\n","protected":false},"template":"","class_list":["post-3476723","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/3476723","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/3476723\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=3476723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}