网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > WordPress
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   IP: 112.87.85.4
Old 2015-06-14, 07:01 AM
Jesup Jesup is offline
初级会员
 
Join Date: 2011-04-09
Posts: 1
Jesup 现在声名狼藉
Default wordpress 实现编辑器中添加分页(nextpage)按钮

相信现在使用wordpress3.0发布文章,添加文章时在编辑器上只会看得到一个more标签(摘取文章摘要),但是有时候写的文章字数比较多,放在一页会影响读者的阅读兴趣,所以需要将长文章分页,这样不会引起读者心里上的反感。

文章分页功能在WordPress 1.5版本中的文章编辑器中有这个功能,但是不知为什么后来从编辑器中去掉了,不过文章分页并未真正的消失,我们可以通过修改程序代码再现文章分页的功能。在这我将提供两种方法:

一、文章分页的标签是:< !– nextpage –>,我们可以在文章的HTML编辑状态下,在需要分页的地方添加"< !– nextpage –>"即可。

二、通过修改代码,将文章分页快捷键调出来。





1.首先打开/wp-includes/js/quicktags.dev.js文件,找到131行,找到如下代码:

我们需要将两行注释号去掉,让包含其中的代码生效。改后的代码如下:

edButtons[edButtons.length] =
new edButton('ed_next'
,'page'
,'<!--nextpage-->'
,''
,'p'
,-1
);

然后再找到如下的代码:

//t.Buttons[t.Buttons.length] = new edButton(name+'_next','page','<!--nextpage-->','','p',-1);

同样也是将注释号去掉,让其代码生效。改后代码如下:

t.Buttons[t.Buttons.length] = new edButton(name+'_next','page','<!--nextpage-->','','p',-1);

2、然后再找到/wp-includes/js/quicktags.js文件。在文件中找到此段代码:

edButtons[edButtons.length]=new edButton("ed_more","more","<!--more-->","","t",-1);

然后在代码的后边加上如下的代码:

edButtons[edButtons.length]=new edButton("ed_next","nextpage","<!--nextpage-->","","p",-1);

再找到如下的代码:

j.Buttons[j.Buttons.length]=new edButton(a+"_more","more","<!--more-->","","t",-1);

将在后边加上如下的代码:

j.Buttons[j.Buttons.length]=new edButton(a+"_next","nextpage","<!--nextpage-->","","p",-1);

3、然后再找到/wp-admin/includes/post.php文件。找到1451行中找wp_more标签,

$mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv' ));

在后边加上:'wp_page'(包括单引号)。代码如下:

$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' ));

这时你就可以在后台的编辑文章和添加新文章页面的可视化编辑器上看到一个跟more标签相似的图标,同样在代码编辑器也会相应出现一个nextpage按钮。

4、需要主题中支持分页功能,所以在自定义主题时,需要手动添加代码到文章页(single.php)。找到主题中single.php文件中的<?php the_content();?>代码,

然后在它后面添加如下代码:

<?php

wp_link_pages('before=<div id="page-links">&next_or_number=number');

wp_link_pages('before=&after=</div>&next_or_number=next&previouspagelink=上一页&nextpagelink=下一页');

?>
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Steps to Change Your Table Prefix in WordPress Abby WordPress 0 2014-04-14 03:40 PM
Install WordPress on IIS topvip Blog(博客)/Wiki(维客)/RSS/Cms 1 2010-01-25 08:31 PM
让wordpress首页显示特殊页面(flash首页等) yahoo Blog(博客)/Wiki(维客)/RSS/Cms 0 2009-02-25 06:58 AM
wordpress 搜索引擎优化的二十条实用技巧 car 搜索引擎优化 0 2008-03-11 08:33 AM
WordPress 中文包 sunshine Blog(博客)/Wiki(维客)/RSS/Cms 0 2007-03-12 10:16 AM

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 11:06 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.