Skip to content

Commit e7c72ad

Browse files
author
Miika Arponen
committed
Merge branch 'Namespace' of github.com:devgeniem/dustpress into Namespace
2 parents be6d35b + bce815e commit e7c72ad

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,18 @@ Example:
258258

259259
### pagination
260260

261-
# TERIS TEKEE
261+
`pagination` helper prints out a basic pagination for your template. It takes the data from your model as parameters and calculates the number of pages based on the `posts per page` value. It then prints out an `ul` element containing the page links with the corresponding page as a query parameter. The helper accepts the following parameters:
262262

263+
- `per_page`: The number of items a single page should have.
264+
- `items`: The amount of items in your data set. For example this could be the post count.
265+
- `page_label`: The query parameter for the pagination links. The default is `paged`.
266+
- `hash`: The hash link to be added at the end of the pagination links.
267+
268+
Example:
269+
270+
```
271+
{@pagination per_page=10 items=item_count page_label="paged" hash="posts-section-id" }
272+
```
263273
### permalink
264274

265275
`permalink` helper emulates WordPress' native `get_permalink()` function. It takes one parameter, `id`, that tells it what post's permalink to give. It defaults to current post's id.

helpers/pagination.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ public function output() {
2727
$prev_page = $cur_page - 1;
2828
$next_page = $cur_page + 1;
2929
$per_page = (int) $params->per_page;
30-
$rows = (int) $params->rows;
30+
$items = (int) $params->items;
3131
$hash = $params->hash ? '#' . $params->hash : '';
3232
$this->page_label = $params->page_label ? $params->page_label : 'paged';
3333

34-
// More rows than the set per_page
35-
if ( ( $rows - $per_page ) > 0 ) {
36-
$page_count = ceil( $rows / $per_page );
34+
// More items than the set per_page
35+
if ( ( $items - $per_page ) > 0 ) {
36+
$page_count = ceil( $items / $per_page );
3737

3838
$first_page = 1;
3939
$last_page = $page_count;

0 commit comments

Comments
 (0)