[英]Pagination for custom wordpress plugin backend
我有一個自定義插件,里面有很多桌子。 這就是為什么我需要適當的分頁。 現在我有一個分頁,但是它順序顯示所有1到80。 這是分頁代碼。
<?php
echo '<div id="pager">Page : <div class="btn-group">';
while( $loopLimit != $loopStart )
{
echo '<a class="btn" href="admin.php?page=wp-glossary&requireTab=viewDelEditWord&totalItems='.$totalItems.'¤tPage='.$loopStart.'&orderByWord='.$_REQUEST["orderByWord"].'"';
if ($loopStart == $currentPage) {echo ' id="activeParer"';}
echo '>'.$loopStart.'</a>';
$loopStart ++ ;
}
echo '</div></div>';
?>
這是當前的固定視圖:
我想要1 2 3 4 .... 10 11 12這樣。 我如何改變這個。 任何想法?
請嘗試以下代碼。 讓我知道
echo '<div id="pager">Page : <div class="btn-group">';
$loopStart = 1;
$currentPage = 4;
$loopLimit = 100;
$start_number_diplay = 5; // Number where you display in paganation in start and end.
$middle_number_diplay = 3;
$i = $j = 1; $total_pagination_display = 10;
while( $loopLimit != $loopStart )
{
if( ($loopStart == ($start_number_diplay+1)) || ($total_pagination_display == $j)) {
echo '<a class="btn" >...</a>';
$j++;
}
echo '<a class="btn" href=""';
if ($loopStart == $currentPage) {
echo ' id="activeParer"';
}
if(($loopStart <= $start_number_diplay) ) {
echo '>'.$loopStart.' </a>';
$j++;
}
else if( (($loopStart%10) == 0) && ($i <= $middle_number_diplay) ) {
echo '>'.$loopStart.' </a>';
$i++;
$j++;
}
$loopStart ++ ;
}
echo '</div></div>';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.