<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Chiamate a categoria per elenco POST]]></title><description><![CDATA[<p dir="auto">Buonasera a tutti, per la gestione di una parte della home del mio sito c'è questo php qua sotto:</p>
<pre><code> &lt;!-- INNER content2 --&gt;
    &lt;div id="inner"&gt;  
    
    [B]&lt;?php $issuesCategory = get_option('tb_home_issues_category'); ?&gt;[/B]
    
    &lt;h3&gt;News dalla Regione&lt;span&gt;&lt;/span&gt;&lt;/h3&gt;
    
    &lt;?php
    $args = array();
    
    $args['post_type'] = 'post';
    $args['post_status'] = 'publish';
    $args['posts_per_page'] = 5;
    [B]if ($issuesCategory) {[/B]
[B]        $excludeCategory = '-' . $issuesCategory;[/B]
[B]        $args['cat'] = $excludeCategory;[/B]
[B]    }[/B]
    
    $tbQuery = new WP_Query($args);
    $latestIndex = 1;
    
    if ($tbQuery-&gt;have_posts()) : while ($tbQuery-&gt;have_posts()) : $tbQuery-&gt;the_post();
    ?&gt;
    
    &lt;?php $postID = get_the_ID(); ?&gt;
    &lt;?php $postTitle = get_the_title($postID); ?&gt;
    &lt;?php $postPermalink = get_permalink($postID); ?&gt;
    
    &lt;?php
    if ($latestIndex == 5) {
        $newsClass = 'news width50 right';
        $dfs = 'small';
        $tSize = 'dfs';
    } 
elseif ($latestIndex == 4) {
        $newsClass = 'news width50 left';
        $dfs = 'small';
        $tSize = 'dfs';
    }
elseif ($latestIndex == 3) {
        $newsClass = 'news width50 left';
        $dfs = 'small';
        $tSize = 'dfs';
    }


elseif ($latestIndex == 2) {
        $newsClass = 'news width50 left';
        $dfs = 'small';
        $tSize = 'dfs';
    }


 else {
        $newsClass = 'news';
        $dfs = 'medium';
        $tSize = 'dfm';
    }
    




    ?&gt;




    
    &lt;div class="&lt;?php echo $newsClass; ?&gt;"&gt;
        &lt;div class="doubleFramed &lt;?php echo $dfs; ?&gt; left"&gt;
            &lt;a href="&lt;?php echo $postPermalink; ?&gt;" title="&lt;?php $postTitle; ?&gt;"&gt;
                &lt;?php echo tb_get_thumbnail($postID, $tSize); ?&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        
        &lt;div class="right"&gt;
            &lt;?php
            if ($latestIndex &gt; 1) { ?&gt;
                &lt;div class="newsInfo"&gt;&lt;?php echo get_the_date('l j F, Y'); ?&gt;&lt;/div&gt;
            &lt;?php }    ?&gt;
        
            &lt;h4&gt;&lt;a href="&lt;?php echo $postPermalink; ?&gt;" title="&lt;?php $postTitle; ?&gt;"&gt;&lt;?php echo $postTitle; ?&gt;&lt;/a&gt;&lt;/h4&gt;
            
            &lt;?php
            if ($latestIndex == 1) { ?&gt;
                &lt;div class="newsInfo"&gt;&lt;?php echo get_the_date('l j F, Y'); ?&gt;&lt;/div&gt;
            &lt;?php }    ?&gt;
            
            &lt;?php if ($latestIndex == 1) {
                the_excerpt();
            } else {
                echo '&lt;p&gt;' . tb_max_words(get_the_excerpt(), 18) . '...&lt;/p&gt;';
            } ?&gt;
            
            &lt;a href="&lt;?php echo $postPermalink; ?&gt;" title="&lt;?php $postTitle; ?&gt;" class="tinyButton roundButtonX right"&gt;Leggi tutto&lt;/a&gt;
        &lt;/div&gt;
    &lt;/div&gt;
            
    &lt;?php
    if ($latestIndex == 1) { ?&gt;
        &lt;div class="horDashed"&gt;&lt;/div&gt;
    &lt;?php }    ?&gt;


    
    &lt;?php $latestIndex++; ?&gt;
    
    &lt;?php endwhile; endif; ?&gt;
    
    &lt;?php wp_reset_postdata(); ?&gt;


    &lt;?php
    if ($issuesCategory) { ?&gt;
    
    &lt;?php
    $args2 = array();
    
    $args2['post_type'] = 'post';
    $args2['post_status'] = 'publish';
    $args2['posts_per_page'] = 3;
    $args2['cat'] = $issuesCategory;
    
    $tbQuery2 = new WP_Query($args2);
    $issuesIndex = 1;
    
    if ($tbQuery2-&gt;have_posts()) { ?&gt;
    
    &lt;div class="horDouble"&gt;&lt;/div&gt;
                
    &lt;h4&gt;&lt;span&gt;&lt;/span&gt;&lt;/h4&gt;


    &lt;?php while ($tbQuery2-&gt;have_posts()) : $tbQuery2-&gt;the_post();     ?&gt;
    


    &lt;?php $postID = get_the_ID(); ?&gt;
    &lt;?php $postTitle = get_the_title($postID); ?&gt;
  &lt;?php $postPermalink = get_permalink($postID); ?&gt;
    
    &lt;?php if ($issuesIndex == 1) echo '&lt;div class="news width50 left"&gt;'; ?&gt;
    &lt;?php if ($issuesIndex == 2) echo '&lt;/div&gt;&lt;div class="news width50 right"&gt;'; ?&gt;
    
    &lt;div class="newsInfo"&gt;&lt;?php echo get_the_date('l j F, Y'); ?&gt;&lt;/div&gt;
    &lt;h4&gt;&lt;a href="&lt;?php echo $postPermalink; ?&gt;" title="&lt;?php echo $postTitle; ?&gt;"&gt;&lt;?php echo $postTitle; ?&gt;&lt;/a&gt;&lt;/h4&gt;
    
    &lt;?php if ($issuesIndex == 1) {
        the_excerpt(); ?&gt;
        &lt;a href="&lt;?php echo $postPermalink; ?&gt;" title="&lt;?php echo $postTitle; ?&gt;" class="tinyButton roundButtonX right"&gt;Leggi tutto&lt;/a&gt;
    &lt;?php } ?&gt;
    
    &lt;?php if ($issuesIndex &gt; 1 &amp;&amp; $issuesIndex &lt; 3) echo '&lt;div class="horDashed"&gt;&lt;/div&gt;'; ?&gt;
    
    &lt;?php if ($issuesIndex == 3) echo '&lt;/div&gt;'; ?&gt;
    
    &lt;?php $issuesIndex++; ?&gt;
    
    &lt;?php endwhile; } ?&gt;
    
    &lt;?php if ($issuesIndex &gt; 1 &amp;&amp; $issuesIndex &lt; 3) echo '&lt;/div&gt;'; ?&gt;
    
    &lt;?php wp_reset_postdata(); ?&gt;
        
    &lt;?php    
    }


    $args3 = array();
    
    $args3['post_type'] = 'tb_video';
    $args3['post_status'] = 'publish';
    $args3['posts_per_page'] = 1;
    
    $args3['meta_query'] = array(
        array(
            'key'        =&gt; '_featured',
            'value'        =&gt; 1,
            'compare'    =&gt; '='
        )
    );
    
    $tbQuery3 = new WP_Query($args3);
    
    ?&gt;


    &lt;?php if ($tbQuery3-&gt;have_posts()) : while ($tbQuery3-&gt;have_posts()) : $tbQuery3-&gt;the_post(); ?&gt;
    
        &lt;?php $postID = get_the_ID(); $postTitle = get_the_title(); ?&gt;
        &lt;?php $postURL = get_post_meta($postID, '_url', true); ?&gt;


        &lt;div class="horDouble"&gt;&lt;/div&gt;
        
        &lt;h4&gt;Featured &lt;span&gt;Videos&lt;/span&gt;&lt;/h4&gt;
        
        &lt;div class="video"&gt;
            &lt;div&gt;
                &lt;a href="&lt;?php echo esc_url($postURL); ?&gt;" title="&lt;?php echo $postTitle; ?&gt;"&gt;
                    &lt;?php echo get_the_post_thumbnail($postID, 'videoHome', array('alt' =&gt; $postTitle, 'title' =&gt; $postTitle)); ?&gt;
                &lt;/a&gt;
            &lt;/div&gt;
            
            &lt;div&gt;
                &lt;h4&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php echo $postTitle; ?&gt;&lt;/a&gt;&lt;/h4&gt;
                &lt;div class="newsInfo"&gt;&lt;?php echo get_the_date('l j F, Y'); ?&gt;&lt;/div&gt;
                
                &lt;div class="horDashed"&gt;&lt;/div&gt;
                
                &lt;?php echo '&lt;p&gt;' . tb_max_words(get_the_excerpt(), 40) . '...&lt;/p&gt;'; ?&gt;
            &lt;/div&gt;
        &lt;/div&gt;


    
    &lt;?php endwhile; endif; ?&gt;
    
    &lt;?php wp_reset_postdata(); ?&gt;


    &lt;/div&gt;
    &lt;!-- .INNER content2 --&gt;
</code></pre>
<p dir="auto">che genera due gruppi di articoli presi da due differenti categorie:</p>
<p dir="auto">il primo blocco sono tutti gli articoli che non rientrano nella categoria del secondo blocco di articoli, questo valore viene passato tramite il menù impostazioni del tema.</p>
<p dir="auto">La mia richiesta è quella di esplicitare per i due blocchi due differenti categorie direttamente dentro al codice php.</p>
<p dir="auto">Dove e come devo inserire le chiamate alle categorie?</p>
<p dir="auto">GRAZIE IN ANTICIPO</p>
]]></description><link>https://dev.connect.gt/topic/180950/chiamate-a-categoria-per-elenco-post</link><generator>RSS for Node</generator><lastBuildDate>Wed, 25 Nov 2026 13:19:55 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/180950.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 27 Nov 2012 16:50:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Chiamate a categoria per elenco POST on Wed, 28 Nov 2012 21:12:00 GMT]]></title><description><![CDATA[<p dir="auto">per $arg2['cat'] devi utilizzare l'ID della categoria che vuoi utilizare, usa la stessa sintassi che stai usando con $args['cat'], ma mi raccomando vai a selezionare l'ID della categoria, altrimenti non riuscirai a mostrare quello che cerchi.</p>
]]></description><link>https://dev.connect.gt/post/1098516</link><guid isPermaLink="true">https://dev.connect.gt/post/1098516</guid><dc:creator><![CDATA[andmore]]></dc:creator><pubDate>Wed, 28 Nov 2012 21:12:00 GMT</pubDate></item><item><title><![CDATA[Reply to Chiamate a categoria per elenco POST on Wed, 28 Nov 2012 20:29:38 GMT]]></title><description><![CDATA[<p dir="auto">Con la riga:</p>
<p dir="auto">$args['cat'] = 1;<br />
vado a prendere la categoria numero 1 che ho tra le mie del sito?</p>
<p dir="auto">Nella seconda parte stessa domanda, come passo ad <em><strong>arg2</strong></em> il riferimento ad una altra categoria?</p>
<p dir="auto">grazie mille</p>
<p dir="auto">PS: domattina faccio la prova e vi faccio sapere...</p>
]]></description><link>https://dev.connect.gt/post/1098523</link><guid isPermaLink="true">https://dev.connect.gt/post/1098523</guid><dc:creator><![CDATA[keggy]]></dc:creator><pubDate>Wed, 28 Nov 2012 20:29:38 GMT</pubDate></item><item><title><![CDATA[Reply to Chiamate a categoria per elenco POST on Wed, 28 Nov 2012 20:21:00 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto"><strong>keggy</strong></p>
<pre><code> [B]&lt;?php $issuesCategory = get_option('tb_home_issues_category'); ?&gt;[/B]
</code></pre>
<p dir="auto">Per prima cosa puoi notare che la categoria $issuesCategory viene presa all'interno di una opzione salvata dal tuo tema. Cambiando questa variabile potrai indicare la categoria di appartenenza</p>
<pre><code>    $args = array();

    $args['post_type'] = 'post';
    $args['post_status'] = 'publish';
    $args['posts_per_page'] = 5;
    [B]if ($issuesCategory) {[/B]
[B]        $excludeCategory = '-' . $issuesCategory;[/B]
[B]        $args['cat'] = $excludeCategory;[/B]
[B]    }[/B]
</code></pre>
<p dir="auto">Ma fossi in te, subito sotto a questo codice andrei ad inserire quanto segue:</p>
<pre><code>$args['cat'] = 1;
</code></pre>
<p dir="auto">In questo modo, anche se non in maniera pulita, sostituisci il valore della categoria da escludere ed imposta l'ID alla categoria che invece vuoi caricare in questa sezione. Raggiunto il prossimo blocco di codice&gt;</p>
<pre><code>    &lt;?php
    if ($issuesCategory) { ?&gt;

    &lt;?php
    $args2 = array();

    $args2['post_type'] = 'post';
    $args2['post_status'] = 'publish';
    $args2['posts_per_page'] = 3;
    $args2['cat'] = $issuesCategory;
</code></pre>
<p dir="auto">potresti sostituire il valore collegato alla variabile $args2['cat'], con il valore di un altro ID corrispondente all'altra categoria che vuoi mostrare.</p>
<p dir="auto">Facendo in questo modo dovresti essere in grado di mostrare le categorie che desideri, prova e facci sapere <img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=bb61372b9dc" class="not-responsive emoji emoji-android emoji--wink" style="height:1.4em;width:auto;vertical-align:middle" title=";)" alt="😉" /></p>
</blockquote>
]]></description><link>https://dev.connect.gt/post/1098515</link><guid isPermaLink="true">https://dev.connect.gt/post/1098515</guid><dc:creator><![CDATA[andmore]]></dc:creator><pubDate>Wed, 28 Nov 2012 20:21:00 GMT</pubDate></item></channel></rss>