title: Error in foreach loop whilst grabbing Array items
body: <p>I am trying to get the URL found under "guid" within this WordPress array, however the foreach loop alone is proving back an error.</p>
  
  <p>You'll notice two method I've tried to try get the information out within each foreach loop. I did not run these at the same time, just pasted in two attempts within the foreach to provide examples.</p>
  
  <pre><code>$media_items = get_attachments_by_media_tags('media_tags='.$category-&gt;term_id.'');
  foreach($media_items as $item) {
      echo $item['guid'];
      echo $item-&gt;guid;
  }
  
  $media_items = get_attachments_by_media_tags('media_tags='.$category-&gt;term_id.'');
  $media_items = array();
  foreach($media_items as $item) {
      echo $item['guid'];
      echo $item-&gt;guid;
  }
  </code></pre>
  
  <p>Whole Loop:</p>
  
  <pre><code>&lt;?php
  //for each category, show all posts
  $cat_args=array(
    'orderby' =&gt; 'id',
    'order' =&gt; 'DESC'
     );
  $categories=get_categories($cat_args);
    foreach($categories as $category) {
      $args=array(
        'showposts' =&gt; -1,
        'category__in' =&gt; array($category-&gt;term_id),
        'caller_get_posts'=&gt;1,
        'category__not_in' =&gt; array( 96, 67 ),
      );
      $media_items = get_attachments_by_media_tags('media_tags='.$category-&gt;term_id.'');
      foreach($media_items as $item) {
          echo $item['ID'];
          echo $item-&gt;ID;
      }
  
      $media_items = get_attachments_by_media_tags('media_tags='.$category-&gt;term_id.'');
      $media_items = array();
      foreach($media_items as $item) {
          echo $item['guid'];
          echo $item-&gt;guid;
      }
  
      echo '&lt;pre&gt;'; var_dump($media_items); echo '&lt;/pre&gt;';
      $posts=get_posts($args);
        if ($posts) {
          echo '&lt;h2&gt;'. $category-&gt;name.'&lt;/h2&gt; &lt;br /&gt;';
          foreach($posts as $post) {
            setup_postdata($post); ?&gt;
            &lt;p&gt;&lt;a href="&lt;?php the_permalink() ?&gt;" rel="bookmark" title="Permanent Link to &lt;?php the_title_attribute(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/p&gt;
            &lt;?php
          } // foreach($posts
        } // if ($posts
      } // foreach($categories
  ?&gt;
  </code></pre>
  
  <p>var_dump($media_items);</p>
  
  <pre><code>NULL
  array(1) {
    [0]=&gt;
    object(WP_Post)#564 (24) {
      ["ID"]=&gt;
      int(6074)
      ["post_author"]=&gt;
      string(1) "4"
      ["post_date"]=&gt;
      string(19) "2014-11-24 08:22:44"
      ["post_date_gmt"]=&gt;
      string(19) "2014-11-24 08:22:44"
      ["post_content"]=&gt;
      string(0) ""
      ["post_title"]=&gt;
      string(47) "4255 Research Trends Issue 39 v2 singles online"
      ["post_excerpt"]=&gt;
      string(0) ""
      ["post_status"]=&gt;
      string(7) "inherit"
      ["comment_status"]=&gt;
      string(4) "open"
      ["ping_status"]=&gt;
      string(6) "closed"
      ["post_password"]=&gt;
      string(0) ""
      ["post_name"]=&gt;
      string(47) "4255-research-trends-issue-39-v2-singles-online"
      ["to_ping"]=&gt;
      string(0) ""
      ["pinged"]=&gt;
      string(0) ""
      ["post_modified"]=&gt;
      string(19) "2015-10-22 09:18:35"
      ["post_modified_gmt"]=&gt;
      string(19) "2015-10-22 09:18:35"
      ["post_content_filtered"]=&gt;
      string(0) ""
      ["post_parent"]=&gt;
      int(0)
      ["guid"]=&gt;
      string(113) "http://researchtrends.mktdev.co.uk/wp-content/uploads/2014/11/4255-Research-Trends-Issue-39-v2-singles-online.pdf"
      ["menu_order"]=&gt;
      int(0)
      ["post_type"]=&gt;
      string(10) "attachment"
      ["post_mime_type"]=&gt;
      string(15) "application/pdf"
      ["comment_count"]=&gt;
      string(1) "0"
      ["filter"]=&gt;
      string(3) "raw"
    }
  }
  </code></pre>
  
  <p>Error when using:</p>
  
  <pre><code>$media_items = get_attachments_by_media_tags('media_tags='.$category-&gt;term_id.'');
  foreach($media_items as $item) {
  echo $item['ID'];
  }
  
  Warning: Invalid argument supplied for foreach() in /home/jasdit5/researchtrends.mktdev.co.uk/wp-content/themes/researchtrends/article-archives.php on line 38
  NULL
  
  Fatal error: Cannot use object of type WP_Post as array in /home/jasdit5/researchtrends.mktdev.co.uk/wp-content/themes/researchtrends/article-archives.php on line 39
  </code></pre>