I have custom post type of reviews, I want to limit the number of posts on the page, the standard methods do not work, please help!
<?php
get_header();
?>
<div class="container category_reviews_inner">
<main id="main" class="site-main clearfix">
<div class="main-content" id="content">
<header class="entry-header">
<h1 class="entry-title page-title">Отзывы</h1>
</header>
<div class="entry-content">
<div class="easy_testimonials_grid easy_testimonials_grid_1 easy_testimonials_grid_responsive">
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'post_type' => 'reviews',
'order' => 'DESC',
'posts_per_page' => 6,
'paged' => $paged
);
$arg_cat = array(
'order' => 'DESC',
'hide_empty' => 1,
'exclude' => '',
'include' => '',
'taxonomy' => 'reviews_Categories',
'posts_per_page' => 6,
);
$categories = get_terms( $arg_cat );
foreach( $categories as $cat ){ $arg_posts = array(
'post_type' => 'reviews',
'post_status' => 'publish',
'posts_per_page' => 6,
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'reviews_Categories',
'field' => 'slug',
'terms' => $cat->slug,
)
),
);}
$the_query = new WP_Query($args);
?>
<?php if( $the_query->have_posts() ) : ?>
<!-- cemeteries -->
<?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
<blockquote class="easy_testimonial for_title">
<div class="easy_testimonial_image_wrapper"></div>
<div class="testimonial_body">
<div class="review_title"><?= the_field('review_title') ?></div>
</div>
</blockquote>
<div class="easy_testimonials_grid_row easy_testimonials_grid_row_1">
<div class="easy_testimonials_grid_cell">
<div class="style-clean_style show_thumbs show_title show_position hide_date stars_rating hide_other easy-t-category-kurs-magiya-schastya easy_t_single_testimonial">
<blockquote class="easy_testimonial">
<div class="easy_testimonial_image_wrapper">
<?php if (has_post_thumbnail()): the_post_thumbnail('thumbnail'); else : ?>
<img width="400" height="400" src="<?php bloginfo('template_url'); ?>/imgs/user_icon.png" alt="Отзовик"/>
<?php endif ?>
</div>
<p class="testimonial_author">
<cite>
<span class="testimonial-client"><?php the_title(); ?></span>
</cite>
</p>
<div class="testimonial_body">
<?php the_content(); ?>
</div>
<div style=""class="reviews_link">
<a href="/reviews-category/<?= $cat->slug ?>"
class="easy_testimonial_title w-auto">
#<?= $cat->name ?></a>
</div>
<div class="easy_t_clear"></div>
</blockquote>
</div>
</div>
</div>
<?php endwhile; ?>
<div class="col-md-12 options border-bottom">
<nav class="navigation posts-navigation" role="navigation" aria-label="Записи">
<!-- pagination -->
<div class="nav-links">
<?php
$total_pages = $the_query->max_num_pages;
if ($total_pages > 1){
$current_page = max(1, get_query_var('paged'));
echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => '/page/%#%',
'current' => $current_page,
'end_size' => 1,
'mid_size' => 2,
'total' => $total_pages,
'prev_text' => __('← Предыдущие'),
'next_text' => __('Новые →'),
'add_args' => array()
));
}
?>
</div>
</nav>
</div>
<div class="all_categories">
<h2 class="entry-title page-title" style="text-align: center">Отзывы о курсе:</h2>
<?php
$term = get_queried_object();
$term_id = ( isset( $term->term_id ) ) ? (int) $term->term_id : 0;
$categories = get_categories( array(
'taxonomy' => 'reviews_Categories',
'orderby' => 'DESC',
'parent' => 0,
'hide_empty' => 1,
) );
?>
<?php
foreach ( $categories as $category )
{
$cat_ID = (int) $category->term_id;
$category_name = $category->name;
$cat_class = ( $cat_ID == $term_id ) ? 'active' : 'not-active';
if ( strtolower( $category_name ) != 'uncategorized' )
{?>
#<a href="/reviews-category/<?= $category->slug ?>" class="easy_testimonial_title w-auto"><?= $category->name ?> </a>
<?php }
}
?>
</div>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<p>К сожалению отзывов нету</p>
<?php endif; ?>
</div>
</div>
</div>
</main>
</div>
<?php get_footer(); ?>