Fare chiamate a categorie per homepage

  • Avatar di Sconosciuto

    Buonasera a tutti, per la gestione di una parte della home del mio sito c’è questo php qua sotto:

    <!-- INNER content2 -->
    <div id="inner">

    <?php $issuesCategory = get_option('tb_home_issues_category'); ?>

    <h3>News dalla Regione<span></span></h3>

    <?php
    $args = array();

    $args['post_type'] = 'post';
    $args['post_status'] = 'publish';
    $args['posts_per_page'] = 5;
    if ($issuesCategory) {
    $excludeCategory = '-' . $issuesCategory;
    $args['cat'] = $excludeCategory;
    }

    $tbQuery = new WP_Query($args);
    $latestIndex = 1;

    if ($tbQuery->have_posts()) : while ($tbQuery->have_posts()) : $tbQuery->the_post();
    ?>

    <?php $postID = get_the_ID(); ?>
    <?php $postTitle = get_the_title($postID); ?>
    <?php $postPermalink = get_permalink($postID); ?>

    <?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';
    }

    ?>

    <div class="<?php echo $newsClass; ?>">
    <div class="doubleFramed <?php echo $dfs; ?> left">
    " title="<?php $postTitle; ?>">
    <?php echo tb_get_thumbnail($postID, $tSize); ?>

    </div>

    <div class="right">
    <?php
    if ($latestIndex > 1) { ?>
    <div class="newsInfo"><?php echo get_the_date('l j F, Y'); ?></div>
    <?php } ?>

    <h4>" title="<?php $postTitle; ?>"><?php echo $postTitle; ?></h4>

    <?php
    if ($latestIndex == 1) { ?>
    <div class="newsInfo"><?php echo get_the_date('l j F, Y'); ?></div>
    <?php } ?>

    <?php if ($latestIndex == 1) {
    the_excerpt();
    } else {
    echo '<p>' . tb_max_words(get_the_excerpt(), 18) . '...</p>';
    } ?>

    " title="<?php $postTitle; ?>" class="tinyButton roundButtonX right">Leggi tutto
    </div>
    </div>

    <?php
    if ($latestIndex == 1) { ?>
    <div class="horDashed"></div>
    <?php } ?>

    <?php $latestIndex++; ?>

    <?php endwhile; endif; ?>

    <?php wp_reset_postdata(); ?>

    <?php
    if ($issuesCategory) { ?>

    <?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->have_posts()) { ?>

    <div class="horDouble"></div>

    <h4><span></span></h4>

    <?php while ($tbQuery2->have_posts()) : $tbQuery2->the_post(); ?>

    <?php $postID = get_the_ID(); ?>
    <?php $postTitle = get_the_title($postID); ?>
    <?php $postPermalink = get_permalink($postID); ?>

    <?php if ($issuesIndex == 1) echo '<div class="news width50 left">'; ?>
    <?php if ($issuesIndex == 2) echo '</div><div class="news width50 right">'; ?>

    <div class="newsInfo"><?php echo get_the_date('l j F, Y'); ?></div>
    <h4>" title="<?php echo $postTitle; ?>"><?php echo $postTitle; ?></h4>

    <?php if ($issuesIndex == 1) {
    the_excerpt(); ?>
    " title="<?php echo $postTitle; ?>" class="tinyButton roundButtonX right">Leggi tutto
    <?php } ?>

    <?php if ($issuesIndex > 1 && $issuesIndex < 3) echo '<div class="horDashed"></div>'; ?>

    <?php if ($issuesIndex == 3) echo '</div>'; ?>

    <?php $issuesIndex++; ?>

    <?php endwhile; } ?>

    <?php if ($issuesIndex > 1 && $issuesIndex < 3) echo '</div>'; ?>

    <?php wp_reset_postdata(); ?>

    <?php
    }

    $args3 = array();

    $args3['post_type'] = 'tb_video';
    $args3['post_status'] = 'publish';
    $args3['posts_per_page'] = 1;

    $args3['meta_query'] = array(
    array(
    'key' => '_featured',
    'value' => 1,
    'compare' => '='
    )
    );

    $tbQuery3 = new WP_Query($args3);

    ?>

    <?php if ($tbQuery3->have_posts()) : while ($tbQuery3->have_posts()) : $tbQuery3->the_post(); ?>

    <?php $postID = get_the_ID(); $postTitle = get_the_title(); ?>
    <?php $postURL = get_post_meta($postID, '_url', true); ?>

    <div class="horDouble"></div>

    <h4>Featured <span>Videos</span></h4>

    <div class="video">
    <div>
    " title="<?php echo $postTitle; ?>">
    <?php echo get_the_post_thumbnail($postID, 'videoHome', array('alt' => $postTitle, 'title' => $postTitle)); ?>

    </div>

    <div>
    <h4>"><?php echo $postTitle; ?></h4>
    <div class="newsInfo"><?php echo get_the_date('l j F, Y'); ?></div>

    <div class="horDashed"></div>

    <?php echo '<p>' . tb_max_words(get_the_excerpt(), 40) . '...</p>'; ?>
    </div>
    </div>

    <?php endwhile; endif; ?>

    <?php wp_reset_postdata(); ?>

    </div>
    <!-- .INNER content2 -->

    che genera due gruppi di articoli presi da due differenti categorie:

    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.

    La mia richiesta è quella di esplicitare per i due blocchi due differenti categorie direttamente dentro al codice php.

    Dove e come devo inserire le chiamate alle categorie?

    GRAZIE IN ANTICIPO

  • Avatar di Sconosciuto

    Non hai specificato l’indirizzo di un blog o la ragione del messaggio quando hai creato questo topic.

    Questo forum di aiuto è per blog ospitati su WordPress.com. Se la tua domanda riguarda un blog WordPress autonomo allora puoi trovare aiuto su WordPress.org forums.

    Se non conosci la differenza tra WordPress.com e WordPress.org, potrai trovare questa informazione utile.

    Se hai dimenticato di includere un collegamento al tuo blog, puoi fare una replica e includerlo sotto. Aiuterà le persone a rispondere alla tua domanda.

    Questo è un messaggio automatico.

  • Avatar di Sconosciuto

    Ciao :)
    Questo è il forum per chi ha i blog su WP.com. Ti conviene postare o sul forum italiano:
    http://www.wordpress-it.it/forum/
    o sul forum ufficiale di WordPress.org (in inglese):
    http://wordpress.org/support/

    sicuramente lì troverai un valido aiuto :)

    Marco.

  • L'argomento ‘Fare chiamate a categorie per homepage’ è chiuso a nuove risposte.