谁能向我解释如何为我们在 WordPress 数据库中的内容实现分页?我们有大约 2000 条记录,我不想在单个页面中显示它们。
有人可以帮忙吗?这是我拥有的代码,我可以显示我的数据库的内容
<?php
require_once( dirname(__FILE__) . '/wp-load.php' );
global $wpdb;
$table = $wpdb->prefix."car_saver";
$data = $wpdb->get_results("SELECT * FROM " . $table );
if(count($data))
{
?>
<table width="700" cellspacing="0" border="0">
<thead>
<tr>
<th>id</th>
<th>Make</th>
<th>Model</th>
<th>Sub Model</th>
<th>MSRP</th>
<th>Utility</th>
<th>Feature</th>
<th>Year</th>
</tr>
</thead>
<tfoot>
<tr>
<th>id</th>
<th>Make</th>
<th>Model</th>
<th>Sub Model</th>
<th>MSRP</th>
<th>Utility</th>
<th>Feature</th>
<th>Year</th>
</tr>
</tfoot>
<tbody>
<?php
foreach($data as $p): ?>
<tr>
<td align="center"><?php echo $p->car_id; ?></td>
<td align="center"><?php echo $p->Make; ?></td>
<td align="center"><?php echo $p->Model; ?></td>
<td align="center"><?php echo $p->subModel; ?></td>
<td align="center"><?php echo $p->MSRP; ?></td>
<td align="center"><?php echo $p->Utility; ?></td>
<td align="center"><?php echo $p->Feature; ?></td>
<td align="center"><?php echo $p->Year; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php
}
else echo "data not found";
?>