{"id":609,"date":"2015-09-27T19:14:53","date_gmt":"2015-09-27T17:14:53","guid":{"rendered":"https:\/\/it.wordpress.org\/forums\/topic\/tax_query-e-relazione-or-nessun-post-estratto\/"},"modified":"2015-09-27T19:14:53","modified_gmt":"2015-09-27T17:14:53","slug":"tax_query-e-relazione-or-nessun-post-estratto","status":"publish","type":"topic","link":"https:\/\/it.wordpress.org\/support\/topic\/tax_query-e-relazione-or-nessun-post-estratto\/","title":{"rendered":"tax_query e relazione &#8220;OR&#8221; -&gt; nessun post estratto"},"content":{"rendered":"<p>Ciao a tutti,<\/p>\n<p>Sto costruendo un tema per il mio sito web personale e ho creato una tassonomia personalizzata per le foto. Sto cercando di estrarre i post che rispondono a <strong><code>term1 OR term2<\/code><\/strong>. Poi utilizzo get_posts($args) per la lista dei post.<br \/>\nEcco l&#8217;array degli argomenti:<\/p>\n<pre><code>$args = array(\n        &#039;post_type&#039; =&gt; &#039;attachment&#039;,\n        &#039;post_mime_type&#039; =&gt;&#039;image&#039;,\n        &#039;posts_per_page&#039; =&gt; -1,\n        &#039;tax_query&#039; =&gt; array(\n            &#039;relation&#039; =&gt; $a[&#039;rel&#039;], \/\/ Qui il problema\n            $tq\n        ),\n        &#039;orderby&#039; =&gt; $orderby,\n        &#039;order&#039; =&gt; $order\n    );<\/code><\/pre>\n<p><code>$tq<\/code> \u00e8 un array di array contente ogni singolo termine che mi serve, relazionato con &#8220;OR&#8221;.<br \/>\nFunziona finch\u00e8 non utilizzo <code>&#039;relation&#039; =&gt; &#039;OR&#039;<\/code> e, senza, funziona con la logica &#8220;AND&#8221;, ho eseguito dei test.<\/p>\n<p>Ogni aiuto sar\u00e0 apprezzato.<\/p>\n<p>Grazie!<\/p>\n","protected":false},"template":"","class_list":["post-609","topic","type-topic","status-publish","hentry","topic-tag-get_posts","topic-tag-or","topic-tag-relation","topic-tag-tax_query"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/609","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/609\/revisions"}],"wp:attachment":[{"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}