Pagination for Pages

Download Pagination for Pages at WordPress.org

Pagination for Pages is a WordPress plugin that allows you to easily create pagination style navigation elements for pages (or any other custom post type). It uses a numerical based system along with next & back navigation elements.

The plugin includes a single function, pagination_for_pages(), that accepts a single parameter, $getPagesQuery. The parameter is fed to get_pages(); default options are “sort_column=menu_order&sort_order=asc“. Override that with whatever you want from the get_pages() documentation. The function returns an unordered list with the class of paginationForPages.

Example

We’re using this plugin in the Project section of our website. Take a look at the bottom of the Neotech Aqua project page for a visual example. Here’s the code that we’re running:

single-project.php template

<?php
 	if (function_exists('pagination_for_pages')) {
 		echo pagination_for_pages('post_type=project&sort_column=post_date');
 	}
?>

style.css file

.paginationForPages {
	list-style:none;
	text-align:center;
	margin:0;
	padding:0;
}
.paginationForPages li {
	display:inline;
	font-size:.9em;
	padding:0 .25em;
}

New feature requests? Need support? Bug reports? Customizations? Drop a comment.

History

  • 0.1: Initial release, very bare bones.

36 Responses to Pagination for Pages

  1. December 14, 2011 Andres

    I am trying to use your plugin to only show the children of the current page. I have tried many things but nothing is working. “child_of” does not seem to be working. Any ideas?


    post_parent."&echo=0")');
    }
    ?>

    • December 14, 2011 Andres


      if (function_exists('pagination_for_pages')) {
      echo pagination_for_pages('post_type=project&sort_column=post_date');
      }

    • December 15, 2011 Matt McInvale

      The plugin is only designed to work with items at the same level in the hierarchy. You would have to modify it to work with children.

  2. January 30, 2012 web desain

    you should provide screen shot for the result of your plugin work. not only show the code source

  3. April 5, 2012 KevEd

    Hi,
    I have a problem in WP 3.3 where only four posts show on my http://www.factionbikeco.com/racing/ page, there are 9 posts assigned to the racing category (I use posts-to-page plugin to assign category posts to that page).
    I tried your plugin but no pagination shows up. I put the php code from the single-project example into several templates and added the CSS sample code.
    I’m using Sideways theme with conventional vertigal blog layout.
    I’m not sure where in the teplate files the code should be placed.

    Thanks in advance.

  4. April 9, 2012 kevEd

    Hi thanks for looking, the editor has hidden the page while adding images. I fixed the error, it was due to a plugin ‘page and post lister’ .

  5. April 10, 2012 Naomi

    I am trying to use your plugin as I cannot find any others for pages. I have installed it on my wordpress website and added the above example code to my index.php file (since I didn’t know where else to put it) and added the css to my custom css file. All that to say is that nothing happens. Where do I control which pages wrap to another page? Or call up the plugin for that particular page? Determine the length of a page before wrapping?
    I’m not very familiar with wordpress coding. If any help could be given it would be much appreciated.
    Thanks!

    • April 11, 2012 Matt McInvale

      The example code only works for a custom post type that we have setup on this site. If you want to use this on your site, you’ll need to change the parameters you send into the function.

  6. April 20, 2012 Trevor

    I downloaded the plugin and need some guidance.
    I have a single page created with 3 sub-pages within a drop menu.

    example:
    Main Page
    page 1
    page 2
    page 3

    I wish to simply add navigation to the bottom of each of the 3 pages to toggle between. What code should I be copying? Where am I pasting it to? What elements am I changing in the code to function as desired? Any help would be most appreciated!

    Thanks

    • August 20, 2012 Raph

      I can help you with your navigation – If you can help me make this Plugin runnin.

      I installed and added the code to the page.php

      no errors and no function and I can see nothing?

  7. August 20, 2012 Raph

    Hi,

    I installed it and put the code into the page.php – but there is no result.

    No errors and no funtion I can not see anything.

    What I els do I have to do

    is it possible that this thing is only working with posts not pages?

    • August 20, 2012 Matt McInvale

      Raph, what code are you using in your page template? The plugin works with any post type.

  8. March 7, 2013 Jason

    Hi Matt,

    this pagination plugin has the feature like
    <>?

    Or it just add numbers to the pagination and will stretch the page or wrap below.

    • March 7, 2013 Matt McInvale

      That is not a feature of this plugin.

      • March 7, 2013 Jason

        I know this plugin do not have this feature thats why I post here and hope you can add it. I have lots of pages and the pagination just wrap down the page and look ugly.

        • March 7, 2013 Matt McInvale

          There are no plans to add that feature at this time.

          • March 7, 2013 Jason

            ok no problem

        • March 7, 2013 Jason

          Maybe I didnt explain myself clearly, look at your project examples page, you have 28 pages now 1 2 3 4 5 6 7 8 9 10 11 12 13–28, if you add more pages say over 30, the pagination numbers will wrap down. Hope you can add feature like max pagination show will be 20, if more than 20 will show a next 10, or something.

  9. March 7, 2013 Jason

    Sorry the code did not display..

    What I mean is like prev 10 or next 10, if not the number will keep adding and stretch a long line to your page.

  10. April 5, 2013 Mike

    Hi there, I’m going to try your plugin. I’m new to the coding aspect of this. PHP etc…

    Where do I drop the code into to make this plugin work? I’m fairly sure it just doesn’t work once it’s enabled right?

    I see in the readme that there is a line of code, but where do I put it? For those not so code savvy it’d be helpful to add a little extra example.

    Please let me know! Thanks!

    • April 5, 2013 Mike

      I also want to add that I’m using this to paginate between pages. Not posts. Thanks!

      M

    • April 5, 2013 Matt McInvale

      page.php of your active theme would be a good place to start.

      • April 5, 2013 Mike

        Ok so do some templates have it labeled as main-page.php? Or is this something I won’t be able to access through the editor?

        Once I’m there, then what? :)

        I do appreciate any help. I’ve never modified the php before. Sorry if it’s totally pedestrian to you but it’s new stuff for me.

        cheers!

        • April 6, 2013 Matt McInvale

          That is possible. You’ll want something like this;

          if (function_exists(‘pagination_for_pages’)) {
          echo pagination_for_pages(‘post_type=page&sort_column=post_date’);
          }

          • April 6, 2013 Mike

            Does that go before any specific line or do I insert that code into the existing section?

            Here’s what I’m looking at:

            If this isn’t the right page then just let me know. I’ll dig further in the backend.

            Thanks Matt.

          • April 6, 2013 Mike

            sorry code didn’t show… anyway, do I put it in before the end of the php section?

          • April 6, 2013 Mike

            So if I want to only show certain pages… for instance if they have an order? 1,2,3,4,5 etc…

            First one is titled “Contributors” with a grid of 18 images, then the page navigation would be at the bottom. this first page would be 1…

            subsequent from there would be contributors 2, contributors 3 etc…

            So I only want to paginate on a specific page and not the whole site and have it’s other pages as pagination beneath on that one page (contributors 2 etc) and the subsequent pages…

            Would that code be right? I got a syntax error and the site broke. I know I’m missing something here. trying to wrap my head around it. I seems easy enough but I feel I’m missing some key components.

            Thanks

          • April 8, 2013 Matt McInvale

            The level of support you’re looking for goes beyond what I can provide via comments. You should hire a developer to help you implement this..

  11. April 25, 2013 vijay

    hi matt…very nice post..it really helped me. :)
    is there any easy option to set pagination for a child pages.??? for example like i have about us page but it has 5 child pages…so can i show pagination for 5 child pages on about us page..???
    page-about us
    e.g.
    previous> 1.2.3.4 <next

    • April 25, 2013 vijay

      or it can be

      previous> Page 1 of the 4 <next

  12. June 23, 2013 steve

    This is very difficult documentation to follow. What code, in what page, do I paste where?

    Your readme file says to post this:
    (but it doesn’t say where to paste it. pages.php I assume). I did that and it didn’t work.

    But in a comment above you tell someone to use this:
    if (function_exists(‘pagination_for_pages’)) {
    echo pagination_for_pages(‘post_type=page&sort_column=post_date’);
    }

    I pasted this in ever file I could think and it didn’t work.

    So, do we use both? And where do we paste them? Do we need to add css? What code do we use. Where do we paste it?

    • June 23, 2013 steve

      somehow a line in my question got cut out. Your readme file says to post this:
      ?php echo pagination-for-pages(''); ?>

      Sorry that got cut out.

    • June 23, 2013 Matt McInvale

      It depends on how you are using it and how your theme is programmed. Generally it would be page.php

  13. June 23, 2013 steve

    Which piece of code goes in the page.php? and does it matter where it goes (top of page. bottom it)? Do we need to add css or will template css work for it?

  14. July 22, 2013 Waseem Abbas

    Where in page.php i paste this code?

    if (function_exists(‘pagination_for_pages’)) {
    echo pagination_for_pages(‘post_type=page&sort_column=post_date’);
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.