Domanda

Dato che sto usando lo strumento jQuery "scorrevole" per la sezione dei post correlati (vedi esempio qui), Mi chiedevo come posso implementare un offset in modo che nel primo ciclo mostrerà i primi 4 post, quindi i prossimi 4 post correlati ecc. Sto pensando di creare 3 loop del genere in questo momento, mostrando gli ultimi 12 post correlati in generale.

La mia configurazione attuale sembra così: (Aggiornato!)

           <h2>Related Posts</h2>                       


<!-- "previous page" action -->
<a class="prev browse left"></a>

<!-- root element for scrollable -->
<div class="scrollable" id=chained>   

   <!-- root element for the items -->
   <div class="items">


                            <?php 
                            $backup = $post;
                            $tags = wp_get_post_tags($post->ID);
                            if ($tags) {
                                $tag_ids = array();
                                foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;

                                $args = array(
    'tag__in' => $tag_ids,
    'post__not_in' => array($post->ID),
    'posts_per_page'=> 12
);

                                $my_query = new WP_Query( $args );
if( $my_query->have_posts() ):
?>  




      <div>


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

        the_title();

        // if this is not the last post
        // and remainder of current post plus one then divided by four is zero
        // close the container and open a new one
        if( $my_query->current_post != ( $my_query->post_count - 1 ) && ( ( $my_query->current_post + 1 ) % 4 ) == 0 ):
            ?>
            </div>

<div>
  <?php
        endif; 

 endwhile;
    ?>

            </div>



</div></div>

<!-- "next page" action -->
<a class="next browse right"></a>


<br clear="all" />

Tuttavia, non so come implementarlo nel codice esistente. Non sono sicuro che sia possibile o se devo prima usare un modo diverso per creare il mio loop per farlo funzionare?

Grazie mille in anticipo! :)

Modifica: ultimo aggiornato il 16 ottobre. Non l'ho ancora capito, per favore aiutatemi!

Nessuna soluzione corretta

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange
scroll top