A
A
Alonse122020-07-23 16:15:54
PHP
Alonse12, 2020-07-23 16:15:54

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
5f198d806b5e1731720442.png
. 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

3 answer(s)
A
Alexander Sobolev, 2020-07-23
@san_jorich

make an ajax request

A
Anton Plawkevich, 2020-07-23
@antowa_plawkevich

<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>

A
Alonse12, 2020-07-24
@Alonse12

Thank you all, I decided through the data attribute

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question