WordPress Plugin : Multipage Toolkit

WordPress Plugin : Multipage Toolkit

Yes, I have finally done it. I have added writing a wordpress plugin to my repertoire of skills. This is the first time I have ever released code for other people to use , so please be gentle.

This plugin has been written to overcome something that is a personal bugbear about WordPress for me and that is its multiple page posts. The built-in function that provides pagination for posts is very limited and just does not give you the flexibility to find the perfect navigation system for your blog.

WordPress as standard has the ability to paginate your posts, i.e. split very long posts over separate pages. You do this by using the <!–nextpage–> tag to create page breaks, the real shortfall of the built-in function is there is no way of adding titles or headings to these pages – something like index or content list, so readers can jump straight to specific areas – this is commonly seen on hardware review sites.

I wrote this plugin to try and improve this area and open up even more possibilities with WordPress.

My plugin provides 3 functions.

  • Add titles or headings to each page (using <!–pagetitle:–>)
  • Display number of pages on index pages (TA_display_pages)
  • Quick jump and title navigation options (TA_content_jump)

Very easy to use and very simple to integrate in to any theme.

Installation

  • Download file (here)
  • Unzip and place directory in to your “plugins” folder (/wp-content/plugins/)
  • Activate plug-in through the admin panel

Change Log

Version 2.6 (5th Sept 2008)
Added auto insertion for Pages as well as Posts
Fixed issues with saving settings
Fixed html and code entry in to text boxes

Version 2.5 (10th July 2008)
SVN broke upload – uploading again

Version 2.4
Changed CSS style naming for the all page links

Version 2.3 (internal release)
Added option to have custom page seperators (including javascript for adverts) on single (ALL) page display
Added function call to use options page settings from inside the theme files
Fixed badly coded string matching (Thanks to Andrei for the fix)
Fixed spelling error in button registration process (Thanks to Jonathan for spotting this)
Fixed maintain trailing slash consistency across site

Version 2.2 (internal release)
Added ALL link Display Text Option
Added new CSS class for ALL link styling (contentjumpall , contentlistall)
Fixed bug where pagetitle followed by nextpage caused errors
Fixed tinymce js cache issues (hopefully..)
Fixed navigation for preview draft posts

Version 2.1 (30th May 2008)
Major Update
New Display ALL pages link, view multipage posts on single page
Added Auto Insert Options page, no more code necessary
Visual Editor Integration, buttons to add page breaks and page titles

Version 1.2 (20th March 2008)
Added a check for trailing slashs and permalink structure for paging
Cleaned up readme.txt for better formatting
Checked compatibility with WordPress 2.5

Version 1.1 – Add new quickjump method – list menu / content table

Version 1.0 – Initial version

Donations

Please consider donating if you have found this plugin useful, it helps pay for my hosting!!


How to use

Function TA_display_pages

This function allows you to simply display page information for your posts on the post listing pages (such as index, categories and tag pages). It can also be used to display the page number of the current page.

Insert the following code into your theme files in the location you want the page information to appear:

<?php if(function_exists(‘TA_display_pages’)) { TA_display_pages(); } ?>

In my case I added the code in to my index.php , category.php and tag.php files. Next to the post title code. Here is the code as used in my index.php file:

<h2><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?></a><?php if(function_exists(‘TA_display_pages’)) { TA_display_pages(‘ <small>(‘,’ pages)</small>’,”,’total’); } ?></h2>

Options

TA_display_pages($firsttext, $lasttext, $midtext, $display_type)

  • $firsttext = ‘ Page ‘
  • $lasttext = ‘ ‘
  • $midtext = ‘ of ‘ (only used when display_type is all)
  • $display_type = ‘all’ (total , current, all)

Examples
 
Default settings      Page 1 of 3

TA_display_pages(‘(‘,’ pages)’,”,’total’)            (3 pages) 
 
TA_display_pages(‘(you are on page ‘,’ now)’,”,’current’)       (you are on page 1 now)

Go on to the next page to read about the other functions.

126 thoughts on “WordPress Plugin : Multipage Toolkit

  1. Hermann

    I think there’s a little bug in the plugin:
    Say we start showing the post in multipage mode; then we switch to “view all”; then we click on the index showing page titles: this is where the bug occurs, because instead of showing again one part of the whole post,the page is being showed as if it was in “view all mode”; btw, when this occurs, page titles aren’t displeyd anymore. It may be some global vars left dirty from “view all” mode.

  2. Hermann

    Sorry I need to post again the following…. I have included the php tags and…. the function call has disapperead!
    ****************************************
    More on the plugin: I have tried the following to enable a Next-only “jump”:

    TA_content_jump(”,”, 0,0, 2 , ”, ‘continue reading..»’, ”, ”, FALSE, ”);

    It works pretty well, but on the last page it is displayed (gray, no hyperlink) even thought there are no more pages. Any hint?

  3. Hermann

    Another tip!
    When page numbering is enabled in front of page titles in the index, the “View all” option is shown as the last page, with a number in front of it.
    This is misleading and brings to confusion IMO.
    You should indent the “View all” link as the title of the index to highlight it, without numbering it.

  4. Hermann

    More on the plugin: I have tried the following to enable a Next-only “jump”:

    It works pretty well, but on the last page it is displayed (gray, no hyperlink) even thought there are no more pages. Any hint?

  5. Hermann

    One other nice feature would be to enable a function that prints the page title automatically, grabbing it from the pagetitle tag.

  6. Hermann

    This plugin is AMAZING! I wonder how the WP team left out such a functionality.

    Well done Tarkan.

    One question: is it possible to call TA_content_jump in a way only the next page (link, title or number) is shown?
    Very smart. Why? Oh well usually you begin navigation reading a page and then clicking somewhere to go on the next page, so a link at the end of the page may be very useful; right aligned.

    Further on I would place the index.

  7. Oliver

    Hi Tarkan,

    Yeah that is a little more complex and beyond me. But this works for me for now. 🙂 If you do make this available in an update, it would be great.

    I’m currently inserting the code manually as I find it much more flexible. Thanks for a fabulous plugin.

    Oliver

  8. Tarkan Post author

    Hi Oliver,

    Thanks for your code and comments.

    I’ve been looking at doing this but without modifying theme files – my method was to modify the title function on the fly.

  9. Oliver

    Grr.

    call it with:

    display_title <– this needs to be followed by ( and ) and; but the comment box strips php. It also needs to be enclosed by php tags.

    put it above:

    the_content

  10. Oliver

    The above should say… (I forgot you can’t insert php…

    Call:

    –remove the spaces here between the < and ? and php

    Put above:

    Make sense?

  11. Oliver

    For those that want to display the title of the page at the top of their multi-page posts, add the following function to TA_multi_toolkit.php. It can go anywhere in the code, except for inside another function. I put mine on line 331.

    In your single.php, call the function like this: It MUST go inside the loop. I put it just above .

    Function:

    function display_title() {
    global $multipage, $page, $posts, $numpages;

    $all_page = get_query_var(‘all’);

    if ($multipage ==’1′) {
    if ($all_page!=’1′) {
    $ta_multipage = get_option(“ta_multipage”);
    $pagetitlestring = ‘//’;
    preg_match_all($pagetitlestring, $posts[0]->post_content, $titlesarray, PREG_PATTERN_ORDER);
    $pagetitles = $titlesarray[1];
    $content = ” . $pagetitles[$page-1] . ”;
    echo $content;
    }
    }
    }

    It will ONLY display the title on posts that you have split into multiple pages and will NOT display on your ‘View All’ page.

    Hope that helps.

    Oliver

  12. Francis

    Hi Tarkan,

    Thanks for the great plugin. I installed it and followed the instructions and inserted the “nextpage” tag but at the end of my page I have the navigation twice… One with the plugin and one from the “nextpage” WP tag… Did I forgot something ? Thx for your help ! 😉

  13. Tarkan Post author

    Max,

    Sadly you cannot do that with the current plugin. I am running a beta with some new titling features which should allow you to do what you are trying to achieve.

  14. Max

    Hello,
    Thanks for creating this plug-in, it’s great!

    I’m trying to get the page title of a multi-page post to display underneath the post title. So if the the post name was “Example Post” and the page title as set by was “Section II”, the post would display as a browser as:

    Example Post
    Section II
    contentcontentcontent…

    I’m new to php so it’s probably very simple, but I can’t figure out how to do that. Thanks for the help!

  15. explore

    I got it to work thank you very much I’ve been looking for this good job keep them coming

  16. explore

    Hi This is a good plugin thanks for the effort. My problem is when i add the next page I can see the it works the next page and the number of page is there. But when I click on it the article opens but with the hole article showing again.
    Anyideas how i can get this to work. Do i have to add bit of the article with the page break in my editor for this to work and not add the hole article at once?

  17. Lee

    Great plugin, thanks.

    I’m using WordPress as a client CMS, and at the moment I’m only using this to show the “nextpage” button.

    Is there an easy way to remove the “pagetitle” button from the WYSIWYG editor within your code – ie, not modifying the core WYSIWYG CSS?

    Cheers,
    Lee.

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.