Plugin / Proper Pagination

Steve Winton

Description

Description

This plugin is primarily aimed at theme developers, and intends to ease the
creation of semantic, usable pagination controls for WordPress listings pages, such as
arhive, author, category, search, tag listings etc.

Inspired by The Loop and WP_Query, this plugin stays out of the theme
developer’s way, allowing her to create the markup needed by providing the
following template tags:

  • pp_has_pagination – determines whether the current ‘view’ has any pagination to display, i.e. whether the content being browsed spans more than 1 page
  • pp_the_pagination – initiates the pagination context, should be called at the beginning of each loop iteration
  • pp_rewind_pagination – resets the pagination context, so that the pagination loop can be iterated over multiple times
  • pp_is_current_page – for use in the pagination loop, returns a boolean indicating whether the current loop iteration is for the current page
  • pp_has_previous_page – for use in the pagination loop, returns a boolean indicating whether there is a previous page, e.g. when at page 1, there is no previous page
  • pp_has_next_page – for use in the pagination loop, returns a boolean indicating whether there is a next page, e.g. when at page N of N, there is no next page
  • pp_the_page_permalink – for use in the pagination loop, echos the permalink for the current page
  • pp_the_previous_page_permalink – for use in the pagination loop, echos the permalink for the previous page
  • pp_the_next_page_permalink – for use in the pagination loop, echos the permalink for the next page
  • pp_the_first_page_permalink – for use in the pagination loop, echos the permalink for the first page
  • pp_the_last_page_permalink – for use in the pagination loop, echos the permalink for the last page
  • pp_the_page_num – for use in the pagination loop, echos the page number of the current page being iterated over

For example, the following arrangement of template tags would provide a rudimentary pagination control:

<?php if (pp_has_pagination()) : ?>
    <div class="pagination">

        <!-- the previous page -->
        <?php pp_the_pagination(); if (pp_has_previous_page()) : ?>
            <a href="<?php pp_the_previous_page_permalink(); ?>" class="prev">newer stories</a>
        <?php else : ?>
            <span class="current prev">newer stories</span>
        <?php endif; pp_rewind_pagination(); ?>

        <!-- the page links -->
        <?php while(pp_has_pagination()) : pp_the_pagination(); ?>
            <?php if (pp_is_current_page()) : ?>
                <span class="current"><?php pp_the_page_num(); ?></span>
            <?php else : ?>
                <a href="<?php pp_the_page_permalink(); ?>"><?php pp_the_page_num(); ?></a>
            <?php endif; ?>
        <?php endwhile; pp_rewind_pagination(); ?>

        <!-- the next page -->
        <?php pp_the_pagination(); if (pp_has_next_page()) : ?>
            <a href="<?php pp_the_next_page_permalink(); ?>" class="next">older stories</a>
        <?php else : ?>
            <span class="current next">older stories</span>
        <?php endif; pp_rewind_pagination(); ?>

    </div>
<?php endif; ?>

The template tags on offer by this plugin provide the theme developer with an
unlimited array of possibilities for marking up the pagination control in a
semantic manner.

For more information, see the original blog post.

Ratings

0
0 reviews

Rating breakdown

Details Information

Version

1.3

First Released

08 Jun, 2009

Total Downloads

6,208

Wordpress Version

2.7 or higher

Tested up to:

2.9.2

Require PHP Version:

-

Tags

Contributors

Languages

The plugin hasn't been transalated in any language other than English.

DIRECTORY DISCLAIMER

The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.

The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.

Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.

While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.

wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.

Keep Leading Your Followers!
Share it for them.