Replace the boring « previous entries and next entries » with fancy paged navigation.

NOTE: This plugin should work on WordPress versions less than 2.0, but it has only been tested on 2.0.5, 2.1 and 2.3. Please report any issues you have on older versions of WordPress.

Usage

Quick Start

  1. Download yaapn.zip and unpack it.
  2. Upload yaapn.php to your plugins directory (usually wp-content/plugins/) and activate the plugin in Administration Panel
  3. In your theme files find all occurences of following (or similar) code:

    <div class="navigation">
    <div class="alignleft"><?php
    next_posts_link('« Previous Entries') ?></div>
    <div class="alignright"><?php
    previous_posts_link('Next Entries »') ?></div>
    </div>

    (in default theme, Kubrick, that will be in index.php, archive.php and search.php)

    Replace with:

    <?php if (function_exists('paging')): paging(); else:?>
    <div class="navigation">
    <div class="alignleft"><?php
    next_posts_link('« Previous Entries') ?></div>
    <div class="alignright"><?php
    previous_posts_link('Next Entries »') ?></div>
    </div>
    <?php endif; ?>
  4. Now where « Previous Entries was, you should see something like this:

    YAAPN with default settings

  5. Enjoy (:

Advanced

Styling

If you don’t like the default styles, change line 11 to your liking or uncomment line 12 and add appropriate definitions to your stylesheet (default class: paging, but you can change that in $template).

Parameters
paging ($count, $template, $template_item,
$prevlabel, $currentlabel, $nextlabel,
$firstlabel, $numberedlabel, $lastlabel,
$skipped, $separator);

$count determines how many numbered links are displayed before and after current page (uses $skipped to indicate that some links are not displayed).

Setting $count to 0 will display links to all pages. WARNING: this may result in a really long list.

$template is the main navigation template.

$template_item is template for items in the numbered list.

Template variables

In $template you can use:

Variable Meaning
%NUMBERED% list of numbered links to pages, separated with $separator
%COUNT% pages count
%CURRENT% current page number
%PREV% link to previous page (if exists), uses $prevlabel
%PREV*% link to previous page (if exists and not first), uses $prevlabel
%NEXT% link to next page (if exists), uses $nextlabel
%NEXT*% link to next page (if exists and not last), uses $nextlabel
%FIRST% link to first page, uses $firstlabel
%LAST% link to last page, uses $lastlabel
%SKIPB% inserts $skipped if there were skipped links in the beginning of numbered list
%SKIPA% inserts $skipped if there were skipped links in the end of numbered list

In $template_item, $numberedlabel and $currentlabel you can use %NUMBER% to insert page number.

In $template_item you can use %ITEM%, which will be replaced with a link (using $numberedlabel) or $currentlabel.

In $lastlabel you can use %COUNT%.

Defaults
paging('<div class="paging"><h4>Page %CURRENT% of %COUNT%</h4>
<ul><li>%FIRST%</li>
<li>%PREV*%</li> %SKIPB% %NUMBERED% %SKIPA% <li>%NEXT*%</li>
<li>%LAST%</li></ul></div>',
'<li>%ITEM%</li>', 2,
'‹ previous', '<b>%NUMBER%</b>', 'next ›',
'« first', '%NUMBER%', 'last »', '<li> ... </li>', '');
Examples
paging('<div class="paging">
%FIRST% %PREV*% (%CURRENT% of %COUNT%) %NEXT*% %LAST%
</div>');
paging('<div class="paging">
%PREV% %SKIPB% %NUMBERED% %SKIPA% %NEXT%
</div>',
'%ITEM% ', 0);

TODO

  • Add option whether to hide or only deactivate %FIRST%, %PREV%, %NEXT% and %LAST%
  • Administration Panel (?)

Changelog

1.05
fixed a little bug that sometimes affected display of upload area in Admin Panel
1.04
first public release
1.0 to 1.03
private betas

Credits

Core idea based on WP-PageNavi by GaMerZ.

Copyright © YaaL 2006