Levdbas
11/27/2019 - 10:51 AM

Pagination

Pagination

$paged = get_query_var('paged') ? get_query_var('paged') : 1;

$main_query_args = array(
    'post_type' => 'post',
    'posts_per_page' => 10,
    'paged' => $paged
);
$main_query = new WP_Query($main_query_args);


        if ($main_query->have_posts()) :
            while ($main_query->have_posts()) :
                $main_query->the_post();
                // hier je item
            endwhile;
        endif;
        wp_reset_query();

        echo paginate_links(array(
        'base' => str_replace(999999999, '%#%', esc_url(get_pagenum_link(999999999))),
        'total' => $main_query->max_num_pages,
        'current' => max(1, get_query_var('paged')),
        'format' => '?paged=%#%',
        'show_all' => false,
        'type' => 'plain',
        'end_size' => 2,
        'mid_size' => 1,
        'prev_next' => true,
        'prev_text' => sprintf('<i class="fas fa-chevron-left"></i>'),
        'next_text' => sprintf('<i class="fas fa-chevron-right"></i>'),
        'add_args' => false,
        'add_fragment' => ''
    ));