Add pagination (NextPage) button method in the WordPress editor

Source: Internet
Author: User

can also use this article said the method in the background editor to add their favorite shortcut button, very convenient, has passed my test, very useful.
———————
Believe that now use wordpress3.0 to publish articles, add an article in the editor will only see a more label (extract article Summary), but sometimes write the article more words, put on a page will affect the reader's interest, so need to be a long article pagination, so that will not arouse the readers in the heart of disgust.

Article paging feature in the WordPress 1.5 version of the article editor has this function, but somehow later removed from the editor, but the article page does not really disappear, we can modify the program code to reproduce the function of the article pagination. In this I will provide two ways:

A, the article pagination label is:<!–nextpage–>, we can in the article HTML edits the state, when needs the page place to add "<!–nextpage–>" can.

Second, by modifying the code, the article page shortcut keys to tune out.

1. First open the/wp-includes/js/quicktags.dev.js file, find 131 lines, find the following code:

We need to remove the two line annotation numbers so that the code that contains them takes effect. The revised code is as follows:

The code is as follows Copy Code
Edbuttons[edbuttons.length] =
New Edbutton (' Ed_next '
, ' page '
, ' <!–nextpage–> '
,”
, ' P '
,-1
);

And then find the following code:

The code is as follows Copy Code
T.buttons[t.buttons.length] = new Edbutton (name+ ' _next ', ' page ', ' <!–nextpage–> ', ", ' P ',-1);

It also removes the annotation number for the code to take effect. The following code is changed:

The code is as follows Copy Code

T.buttons[t.buttons.length] = new Edbutton (name+ ' _next ', ' page ', ' <!–nextpage–> ', ", ' P ',-1);

2, and then find the/wp-includes/js/quicktags.js file. Locate the code in the file:

Edbuttons[edbuttons.length]=new Edbutton ("Ed_more", "more", "<!–more–>", "", "T",-1);

Then add the following code behind the code:

The code is as follows Copy Code

Edbuttons[edbuttons.length]=new Edbutton ("Ed_next", "NextPage", "<!–nextpage–>", "", "P",-1);

And then find the following code:

The code is as follows Copy Code

J.buttons[j.buttons.length]=new Edbutton (A + "_more", "more", "<!–more–>", "", "T",-1);

The following code will be added at the rear:

The code is as follows Copy Code

J.buttons[j.buttons.length]=new Edbutton (A + "_next", "NextPage", "<!–nextpage–>", "", "P",-1);

3, and then find the/wp-admin/includes/post.php file. Find the Wp_more tag in line 1451,

The code is as follows Copy Code

$mce _buttons = apply_filters (' mce_buttons ', Array (' bold ', ' Italic ', ' strikethrough ', ' | ', ' bullist ', ' numlist ', ') ' Blockquote ', ' | ', ' justifyleft ', ' justifycenter ', ' justifyright ', ' | ', ' link ', ' unlink ', ' wp_more ', ' | ', ' spellchecker ', ' Fullscreen ', ' wp_adv ');

Add the following: ' Wp_page ' (including single quotes). The code is as follows:

The code is as follows Copy Code
$mce _buttons = apply_filters (' mce_buttons ', Array (' bold ', ' Italic ', ' strikethrough ', ' | ', ' bullist ', ' numlist ', ') ' Blockquote ', ' | ', ' justifyleft ', ' justifycenter ', ' justifyright ', ' | ', ' link ', ' unlink ', ' wp_more ', ' wp_page ', ' | ', ' Spellchecker ', ' fullscreen ', ' wp_adv ');

Then you can see an icon similar to the more tag in the background edit article and add new article page's visual editor, also in the Code Editor, a nextpage button appears accordingly.

4, need to support paging features in the theme, so when you customize the theme, you need to manually add code to the article page (single.php). Locate the <?php the_content () in the single.php file in the topic;? > Code,
Then add the following code after it:

The code is as follows Copy Code
<?php
Wp_link_pages (' Before=<div id= ' page-links ' >&next_or_number=number ');
Wp_link_pages (' before=&after=</div>&next_or_number=next&previouspagelink= page & nextpagelink= next page ');
?>

If you add your own personalized label, such as the title abbreviation SR for this blog (this SR should be set in brackets), this code is added to the theme support function. Now you can also imitate to make your own personalized tag and set a background button for it, try it quickly.

The code is as follows Copy Code

function Shortright () {return ' www.111cn.net ' > Sanjiang ferry </a> ';}
Add_shortcode (' sr ', ' shortright ');

JS part of the code is this: (Types of things are according to the top of the NextPage label modified)

  code is as follows copy code

edbuttons[ Edbuttons.length] =
New Edbutton (' Ed_sr '
, ' shortright '
, ' [SR] '
, '
', ' sr '
, -1
);
T. Buttons[t.buttons.length] = new Edbutton (name+ ' _sr ', ' shortright ', ' [SR] ', ', ', ' SR ', -1);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.