-3
I want to put an effect Carousel in a session, on the home page, where I pick up the 3 most recent posts. But for this I need the index, change as you do loop.
As it stands, the index appears 0
, for all posts. IE, the first post will stick to the <slide :index="0">
, the second tb and the third equal. I imagine I need to make a condition with count
, for each time you do the loop and pick up 1 post, change the number of index for +1
.
The second post should stay <slide :index="1">
, and the third with <slide :index="2">
; how do I make a condition for the index number to increase +1, as the post is called in the loop?
<div id="carousel3d">
<carousel-3d :perspective="0" :space="200" :display="5" :controls-visible="true" :controls-prev-html="'❬'" :controls-next-html="'❭'" :controls-width="30" :controls-height="60" :clickable="true" :autoplay="true" :autoplay-timeout="5000">
<!-- Define our WP Query Parameters -->
<?php $the_query = new WP_Query( 'posts_per_page=3' ); ?>
<!-- Start our WP Query -->
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<!-- Display the Post Title with Hyperlink -->
***<slide :index="0">***
<span class="title"><a href="<?php the_permalink() ?>"><?php the_title(); ?></span>
<?php the_post_thumbnail(); ?></div>
<!-- Display the Post Excerpt -->
<?php the_excerpt(__('(more…)')); ?>Veja mais</a>
</slide>
<!-- Repeat the process and reset once it hits the limit -->
<?php
endwhile;
wp_reset_postdata();
?>
<p style="text-align: center;">Conheça mais</p>
</carousel-3d>
</div>
But I don’t know how to do it. Someone can help me?
I edited her, I know how else to explain.
– Caroline L
before while $i=0;
<slide :index="<?php echo $i ?>">
and before theendwhile;
place$i++;
– user60252
@Bacco, do you have any problem trying to understand the questions of users, especially beginners? The site is flooded with pending.
– user60252
@Leocaracciolo in this case it is better to ask the users of the pending if they have difficulty understanding the basic functioning of the site. Unfortunately someone must have posted the site as a Helpdesk by mistake (I’m talking in general, not this specific question here). What scares me the most is that users who already have time here have not understood, to be quite honest. And look who has one usually has a yellow frame explaining what to do to reopen, but I don’t see many "attempts" in that direction.
– Bacco
Thank you @Leocaracciolo
– Caroline L