Answer the question
In order to leave comments, you need to log in
How to change value on click?
Good afternoon. There is a slider in which posts are pulled out, the task is to make sure that when switching one post to another, not only the posts change, but also the date of its creation
. Tell me in which direction to move. As an option, iterate over an array of dates, and switch the divs with the date by clicking, but this is not good.
So far, there is such a code that pulls the date of the post
<div class="events__navigation">
<div class="events__button-inner">
<button class="events__button events__prev-button" id="prev-button"></button>
</div>
<?php $data = []; ?>
<?php foreach($posts as $post){ setup_postdata($post); ?>
<?php $data = get_the_date(); ?>
<?php wp_reset_postdata(); } ?>
<div class="events__date"><?php echo $data; ?></div>
<div class="events__button-inner">
<button class="events__button events__next-button" id="next-button"></button>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
<div class="events__navigation">
<div class="events__button-inner">
<button class="events__button events__prev-button" id="prev-button"></button>
</div>
<?php $data = []; ?>
<?php foreach($posts as $post){ setup_postdata($post); ?>
<?php $data = get_the_date(); ?>
<div class="events__date"><?php echo $data; ?></div>
<?php wp_reset_postdata(); } ?>
<div class="events__button-inner">
<button class="events__button events__next-button" id="next-button"></button>
</div>
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question