{"id":4052,"date":"2016-05-27T12:20:14","date_gmt":"2016-05-27T10:20:14","guid":{"rendered":"https:\/\/it.wordpress.org\/forums\/topic\/query-complessa-tra-categorie-e-campi-correlati\/"},"modified":"2016-05-27T17:33:21","modified_gmt":"2016-05-27T15:33:21","slug":"query-complessa-tra-categorie-e-campi-correlati","status":"publish","type":"topic","link":"https:\/\/it.wordpress.org\/support\/topic\/query-complessa-tra-categorie-e-campi-correlati\/","title":{"rendered":"[SOLVED] query complessa tra categorie e campi correlati"},"content":{"rendered":"<p>Buongiorno a tutti, sto tentando in tutti i modi di fare questa cosa ma non riesco:<\/p>\n<p>In pratica vorrei fare una lista, la quale divide i diversi articoli per la loro categoria, questa lista per\u00f2, deve &#8220;pescare&#8221; solo gli articoli correlati attraverso un campo.<\/p>\n<p>In pratica la desiderata \u00e8 avere diversi menu ai quali associo i diversi piatti e in frontend in automatico viene generata una lista divisa per le categorie dei piatti (primi, secondi, bevande, dolci ecc&#8230;).<\/p>\n<p>Ad oggi sono riuscito a fare le due cose divise (lista divisa e filtro per campi), ma non riesco a fare un merge delle due cose.<\/p>\n<p>&#8212;<\/p>\n<p>QUESTO \u00e8 IL CODICE PER I CAMPI CORRELATI:<\/p>\n<pre><code>\n&lt;div class=&quot;blockGroup&quot;&gt;\t\n\t\t\t\t\t\t\t\n\/\/\/ CORRELATI \/\/\/\n&lt;!-- ##########  --  SIMPLE LIST PLATTERS -- ########## --&gt;\n&lt;?php\n  $post_objects = get_post_meta( get_the_ID(), &#039;_ab_theme_select_platter&#039;, true );\n?&gt;\n\n&lt;?php\n  if ($post_objects) :  \/\/ APRO LA CONDIZIONALE: QUINDI SE HO POST FACCIO...\n?&gt;\n\n&lt;div class=&quot;blockGroup&quot;&gt;\n\n  &lt;section class=&quot;simpleList&quot;&gt;\n\n    &lt;ul&gt;\n\n      &lt;?php \n         foreach( $post_objects as $post ): setup_postdata($post); \n       ?&gt; \n       \n       &lt;li&gt; \n\n         &lt;?php  \n           include(locate_template(&#039;contents\/entity-3\/list-item.php&#039;)); \n         ?&gt; \n\n       &lt;\/li&gt;\n \n       &lt;?php endforeach; ?&gt;\n\n     &lt;\/ul&gt;\n\n   &lt;\/section&gt;\n\n&lt;\/div&gt;\n\n&lt;?php else : echo &#039;&#039;; endif; wp_reset_postdata(); ?&gt;\n\n&lt;\/div&gt;\n\n<\/code><\/pre>\n<p>&#8212;<\/p>\n<p>QUESTO \u00e8 IL CODICE PER IL LISTING DIVISO PER CATEGORIE:<\/p>\n<pre><code>\n&lt;div class=&quot;blockGroup&quot;&gt;\t\n  &lt;section class=&quot;simpleList&quot;&gt;\n    \/\/\/ DIVISI PER CAT \/\/\/\n    \n   &lt;?php  \n     $terms = get_terms(&#039;tax_entity_3&#039;); \n     $count = count($terms); \n    ?&gt;\n\n    &lt;?php \n      \n      if ($count &gt; 0) \n\t{ \n          foreach ( $terms as $term) \n\t{ \n     ?&gt;\n\t\t\t\t\n     &lt;h2&gt;&lt;?php echo $term-&gt;name; ?&gt;&lt;\/h2&gt;   \n \n     &lt;ul class=&quot;taxonomy_group&quot;&gt;\n     \n      &lt;?php \n\n      $loop = new WP_Query(\n\tarray( &#039;tax_entity_3&#039; =&gt; $term-&gt;slug )\n      );\n\n      while ( $loop-&gt;have_posts() ) : $loop-&gt;the_post(); ?&gt;\n      \n      &lt;li&gt;\n\n      &lt;?php\n         include(locate_template(&#039;contents\/entity-3\/list-item.php&#039;)); \n      ?&gt;\n\n      &lt;\/li&gt;\n      &lt;?php endwhile; ?&gt;  \n     &lt;\/ul&gt;\n\n&lt;?php } } wp_reset_postdata(); ?&gt;\n\n&lt;\/section&gt;\n&lt;\/div&gt;\n\n<\/code><\/pre>\n<p>&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>GRAZIE<\/p>\n","protected":false},"template":"","class_list":["post-4052","topic","type-topic","status-publish","hentry","topic-tag-categorie"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/4052","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":3,"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/4052\/revisions"}],"predecessor-version":[{"id":4063,"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/4052\/revisions\/4063"}],"wp:attachment":[{"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=4052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}