Please modify your query as:
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$posts_per_page = get_option( 'posts_per_page' );
$artPosts= new WP_Query( array(
'post_type' => 'art',
'posts_per_page' => $posts_per_page,
'post_status' => 'publish',
'orderby' => 'title',
'order' => 'DESC',
'paged' => $paged
));
<?php if ( $artPosts->have_posts() ) : ?>
<?php while ( $artPosts->have_posts() ) : $artPosts->the_post(); ?>
// some code for fetching data
<?php endwhile; ?>
<?php else : ?>
<div class="col-12">
<div class="alert alert-info" role="alert"><?php esc_html_e( 'Sorry, we can\'t find any art gallery!', 'artist' ); ?></div>
</div>
<?php endif; ?>
<div id="pagination">
<?php wpex_pagination($artPosts); ?>
</div>
Put this function in functions.php
file of your child-theme.
if ( ! function_exists( 'wpex_pagination' ) ) {
function wpex_pagination( $query = '' ) {
$prev_arrow = is_rtl() ? 'fa fa-angle-right' : 'fa fa-angle-left';
$next_arrow = is_rtl() ? 'fa fa-angle-left' : 'fa fa-angle-right';
global $wp_query;
$wp_query = $query ? $query : $wp_query;
$total = $wp_query->max_num_pages;
$big = 999999999; // need an unlikely integer
if ( $total > 1 ) {
if ( ! $current_page = get_query_var( 'paged' ) ) {
$current_page = 1;
}
if ( get_option('permalink_structure') ) {
$format="page/%#%/";
} else {
$format="&paged=%#%";
}
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => $format,
'current' => max( 1, get_query_var('paged') ),
'total' => $total,
'mid_size' => 3,
'type' => 'list',
'prev_text' => '<i class="'. $prev_arrow .'"></i>',
'next_text' => '<i class="'. $next_arrow .'"></i>',
) );
}
}
}