Add pagination with multiple category posts

if you want to add the pagination and fetch the post with multiple categories then you can use my following custom code inside wordpress.

$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'category_name' => 'cat-name1,cate-name2',
'posts_per_page' => 10,
'paged' => $paged,
);
$arr_posts = new WP_Query( $args );
if ($arr_posts->have_posts()) :
while ($arr_posts->have_posts()) : $arr_posts->the_post()

Here you need to pass the category name from which you want to fetch the post.
Also, you need to pass the number of post which you want to display on a single page.

 post_class();

>

if ( has_post_thumbnail() ) :
the_post_thumbnail('medium', array( 'class' => 'img-responsive news-img' ));
endif;
 echo get_the_date( 'd.m.Y' ); 

 

 the_title(); 

 the_excerpt();
$total_pages = $arr_posts->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,
'total' => $total_pages,
'prev_text'    => __('« prev'),
'next_text'    => __('next »'),
'add_args'  => array()
));
}
else :
 _e('404 Error: Not Found', ''); 
endif; wp_reset_postdata();