add pagination to wordpress

Sure! Here is a response:

  1. Open your theme's functions.php file.
  2. Add the following code to the functions.php file:
function custom_pagination() {
    global $wp_query;
    $big = 999999999;
    echo paginate_links(array(
        'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
        'format' => '?paged=%#%',
        'current' => max(1, get_query_var('paged')),
        'total' => $wp_query->max_num_pages
  1. Save the functions.php file.

  2. In the template file where you want to display the pagination (e.g., archive.php, index.php), add the following code where you want the pagination to appear:

<?php custom_pagination(); ?>
  1. Save the template file.