P
P
pavel_samael2021-10-13 18:35:12
WordPress
pavel_samael, 2021-10-13 18:35:12

How to enter text from a post not in a loop, but behind a loop in WordPress?

There is a large block that has a slider, and in the slider there are reviews that are added to WP and displayed through the output of posts. But just like the posts, the author who wrote it should also change, and he is behind the block of posts. And it is necessary that when you click on the slider, the author also changes, how can this be done?

<section class="slider__reviews">
        <div class="container">
            <div class="slider__reviews_inner">
                <div class="slider_reviews_left">
                    <div class="slider_reviews_left_top">
                        <p class="slider_reviews_left_top_text community__subtitle subtitle-14">отзывы наших довольных клиентов</p>
                        <h2 class="slider_reviews_left_top_title community__title">Отзывы</h2>
                    </div>
                    <div class="slider_reviews_left_bottom">
                        <div class="slider_reviews_left_bottom_hashtag">
                            <p class="slider_reviews_left_bottom_hashtag_text subtitle-14">#Разработка сайта </p>
                            <p class="slider_reviews_left_bottom_hashtag_text subtitle-14">#SEO-продвижение</p>
                        </div>
                        <h3 class="slider_reviews_left_bottom_name text-24">Екатерина Новикова</h3>
                        <p class="slider_reviews_left_bottom_text text-16">Создание сайта hrbel.by</p>
                        <div class="slider__reviews_number">
                            <div class="swiper-pagination-two swiper-pagination-two_block"></div>
                        </div>
                    </div>
                </div>
                <div class="slider_reviews_right">
                    <div class="swiper swiper-cards swiper-3d swiper-initialized swiper-horizontal">
                        <div class="swiper-wrapper ">
                        <?php
                            $posts = get_posts( array(
                                'numberposts' => -1,
                                'category'    => 4,
                                'orderby'     => 'date',
                                'order'       => 'DESC',
                                'include'     => array(),
                                'exclude'     => array(),
                                'meta_key'    => '',
                                'meta_value'  =>'',
                                'post_type'   => 'post',
                                'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
                            ) );

                            foreach( $posts as $post ){
                                setup_postdata($post); ?>
                                            <div class="swiper-slide cursor-pull">
                                                <div class="slider_reviews_inner_block_img slider_reviews_inner_block_one cursor-pull">
                                                    <p class="text-16 cursor-pull"><?php the_field('текст_отзыва'); ?></p>
                                                </div>
                                            </div>
                            <?php }

                            wp_reset_postdata();?>
                        </div>
                    </div>
                    <div class="slider__nav-wrapper-two">
                        <div class="slider__nav-two">            
                            <div class="swiper-button-prev hends swiper-button-two"></div>
                            <div class="swiper-pagination-two_two  swiper-pagination-two_hidden"></div>

                            <div class="swiper-button-next hends swiper-button-two_two"> </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Bodrosh, 2021-10-14
@Bodrosh

You can, for example, create a variable (array) outside the loop, and collect data into it in the loop itself. After the cycle is completed, everything will remain in it and can be used further.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question