![]() |
|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
#1
IP: 112.87.85.4
|
|||
|
|||
|
相信现在使用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=下一页'); ?> |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
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 |