Wordpress multiple categories by id, shows only first

Viewed 18

i'am trying to publish 3 categories in 3 different rows, i use same code, just changing the category ID, but it shows only first category and it cut it self whole website bellow this code. Can someone tell me please what i do wrong?

<?php
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
            $args = array(
                'post_type' => 'post',
                'post_status' => 'publish',
                'cat' => '1',
                'posts_per_page' => 5,
                'paged' => $paged,
            );
            $arr_posts = new WP_Query($args);

            if ($arr_posts->have_posts()) :

                while ($arr_posts->have_posts()) :
                    $arr_posts->the_post();
            ?>
                    <div class="col-sm-12 col-md-12 col-lg-12 news-box-list mt-2 mb-2">
                        <div class="row align-items-center">

                            <div class="col-sm-12 col-md-4 col-lg-4 col-xl-4">
                                <?php if (has_post_thumbnail()) : ?>
                                    <a href="<?php the_permalink(); ?>" alt="<?php the_title_attribute(); ?>">
                                        <?php the_post_thumbnail('post-thumbnail', ['class' => 'img-fluid rounded-4']); ?>
                                    </a>
                                <?php endif; ?>
                            </div>

                            <div class="col-sm-12 col-md-8 col-lg-8 col-xl-8">
                                <p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
                            </div>
                        </div>
                    </div>
            <?php
                endwhile;
                wp_pagenavi(
                    array(
                        'query' => $arr_posts,
                    )
                );
            endif;
            ?>
1 Answers

Fixed - in case someone would like to use exact code.

<?php
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
            $args = array(
                'post_type' => 'post',
                'post_status' => 'publish',
                'cat' => '1',
                'posts_per_page' => 5,
                'paged' => $paged,
            );
            $arr_posts = new WP_Query($args);

            if ($arr_posts->have_posts()) :

                while ($arr_posts->have_posts()) :
                    $arr_posts->the_post();
            ?>
                    <div class="col-sm-12 col-md-12 col-lg-12 news-box-list mt-2 mb-2">
                        <div class="row align-items-center">

                            <div class="col-sm-12 col-md-4 col-lg-4 col-xl-4">
                                <?php if (has_post_thumbnail()) : ?>
                                    <a href="<?php the_permalink(); ?>" alt="<?php the_title_attribute(); ?>">
                                        <?php the_post_thumbnail('post-thumbnail', ['class' => 'img-fluid rounded-4']); ?>
                                    </a>
                                <?php endif; ?>
                            </div>

                            <div class="col-sm-12 col-md-8 col-lg-8 col-xl-8">
                                <p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
                            </div>
                        </div>
                    </div>
            <?php
                endwhile;
            endif;
            ?>
Related