title: How to fix “Object of class WP_Term could not be converted to string”?
body: <p>I want to loop through each post I have and get the taxonomy/category id. After that I want to output those ids into a single string (not as a numeric value), separated by a space.</p>
  <p>I get this error when I try to echo the string: &quot;Object of class WP_Term could not be converted to string&quot;</p>
  <p>Here is what i have so far:</p>
  <pre><code>&lt;?php
            $taxonomy = wp_get_object_terms($post-&gt;ID, 'categories');
            $ids = &quot;&quot;;
             
            foreach ($taxonomy as $cat) {
                $ids .= $cat;
            }
    ?&gt;
  </code></pre>