-
-
Save parag60288/999ad56d305362899d12485b979ddf49 to your computer and use it in GitHub Desktop.
Simple pagination element with dot separation when large counts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="pagination size1of1 unit"> | |
<?php if($paged == 1): ?> | |
<span class="current"><?php echo $paged ?></span> | |
<?php else: ?> | |
<a class="prev" href="?page=<?php echo ($current_page - 1) ?>">Prev</a> | |
<?php if ($current_page > 2): ?> | |
<a href="?page=1">1</a> | |
<?php endif ?> | |
<?php if ($current_page > 3): ?> | |
<span class="dots">...</span> | |
<?php endif ?> | |
<?php endif ?> | |
<?php if($current_page - 1 > 0): ?> | |
<a href="?page=<?php echo $current_page - 1 ?>"><?php echo $current_page - 1 ?></a> | |
<?php endif ?> | |
<span class="current"><?php echo $current_page ?></span> | |
<?php if ($current_page + 1 < $max_num_pages): ?> | |
<a href="?page=<?php echo $current_page + 1 ?>"><?php echo $current_page + 1 ?></a> | |
<?php endif ?> | |
<?php if($current_page < $max_num_pages): ?> | |
<?php if ($current_page < $max_num_pages - 2): ?> | |
<span class="dots">...</span> | |
<?php endif ?> | |
<a href="?page=<?php echo $max_num_pages ?>"><?php echo $max_num_pages ?></a> | |
<a class="next" href="?page=<?php echo ($current_page + 1) ?>">Next</a> | |
<?php endif ?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment