OK, I am developing a plugin which uses a custom page template. The way the plugin works, it reads a list of items to be displayed from a custom database table, then displays the list. So far, that works fine.
However, I would like to add pagination to this list. Here's an extract from the template:
<div class="container"> <div id="liquid" role="main"> <h2>Our Inventory</h2> <?php // Pull list of vehicles from database $sql = "SELECT `Stock Number`, `VIN`, `Year`, `Make`, `Model` FROM $inv_table ORDER BY `Stock Number` ASC"; $vehicles = $wpdb->get_results ( $sql, ARRAY_A ); ?> <?php global $post; $page = untrailingslashit ( get_permalink ( $post->ID ) ); ?> <!-- display the rows --> <?php foreach ( $vehicles as $vehicle ) : ?> <div> <a href="<?php echo $page. '/' . $vehicle ['VIN']; ?>" > <?php echo $vehicle['Stock Number']; ?> </a> <p> Stock: <?php echo $vehicle ['Stock Number']; ?><br /> VIN: <?php echo $vehicle ['VIN']; ?><br /> Mileage: <?php echo $vehicle ['Mileage']); ?><br /> </p> </div> <div class="clearfix"></div> <?php endforeach; ?> </div> </div>
What I want to do now is paginate with a page break every, say, 20 items.
I've looked around a lot but I can't find anything that does exactly what I'd like it to do...
Any help will be greatly appreciated!