customization – how to display next previous pagination on custom page?


I tried to add pagination my custom page, the pagination number appears but there is no next and previous pagination.

enter image description here

function.php

function pagination($pages = '', $range = 4)

{
$showitems = ($range * 2)+1;

global $paged;
if(empty($paged)) $paged = 1;

if($pages == '')
{
    global $wp_query;
    $pages = $wp_query->max_num_pages;
    if(!$pages)
    {
        $pages = 1;
    }
}

if(1 != $pages)
{
    echo "<ul class="pagination pagination-lg my-4 justify-content-center">";
    if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>&laquo; First</a>";
    if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>&lsaquo; Previous</a>";

    for ($i=1; $i <= $pages; $i++)
    {
        if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
        {
            echo ($paged == $i)? "<li class="page-item active"><a class="page-link" href='".get_pagenum_link($i)."'>".$i."</a></li>":"<li><a href='".get_pagenum_link($i)."' class="page-link">".$i."</a></li>";
        }
    }

    if ($paged < $pages && $showitems < $pages) echo "<li class="page-item"><a href="".get_pagenum_link($paged + 1)."" data-hover="Next" class="next page-link">»</a></li>";
    if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<li class="page-item"><a href='".get_pagenum_link($pages)."' data-hover="Previous" class="prev page-link">«</a>";
    echo "</ul>n";
}

}

popular.php

Popular Videos

‘post’,
‘posts_per_page’ => 20,
‘meta_key’ => ‘post_views_count’,
‘orderby’ => ‘meta_value_num’,
‘paged’ => $paged
);
$custom_query = new WP_Query( $args );
?>
have_posts()) :
$custom_query->the_post();
?>

“>

–>
‘video-img img-fluid’, ‘alt’ => get_the_title()));
}
?>

ID, ‘time’) ); ?>

” title=””>

99% –>

max_num_pages);
}
?>