实现wordpress分页的几种方法
展开全部 wordpress内置了很多分页的函数,我可以通过传参很方便的就完成分页功能,只要你有一些css的基础,很容易就可以实现各式各样的分页样式,我们来看看有哪些一、paginate_links()例: 0, 'before_page_number' => '', 'mid_size' => 2,));?>二、the_posts_pagination()例: 3,'prev_text' =>'上一页','next_text' =>'下一页','before_page_number' => '第 ','after_page_number' => ' 页',) ); ?>三、自定义函数,把以下代码放入主题目录functions.php中// 分页代码function par_pagenavi($range = 3){global $paged, $wp_query;if ( !$max_page ) {$max_page = $wp_query->max_num_pages;}if($max_page > 1){if(!$paged){$paged = 1;}if($paged != 1){echo "?";}if($max_page > $range){if($paged $i";}}elseif($paged >= ($max_page - ceil(($range/2)))){for($i = $max_page - $range; $i $i";}}elseif($paged >= $range && $paged $i";}}}else{for($i = 1; $i $i";}}next_posts_link(' ?');}}模板中调用方法:附带一点css样式仅供参考:#page{width:100%;height:36px;line-height:36px;text-align:left;overflow:hidden;margin-left:auto;margin-right:auto;display:block;text-align:-moz-center;*text-align:center;text-align:center}#page a{text-decoration:none;color:#FFF;background:#282828;display:inline-block;padding:9px 12px;margin:0 5px 0 0;line-height:16px;margin-right:3px}#page a:hover,#page a.current{color:#FFF;background:#32a5e7}
wordpress 页面分页问题:
有好多朋友都会遇到这样的问题,所以把解决方法写出来.供大家参考.打开wp-includes/link-template.php 文件,找到 get_page_link(页面链接),get_attachment_link(附件链接),get_year_link(按年存档页面链接),get_month_link(按月存档页面链接),get_day_link(按天存档页面链接),get_pagenum_link(导航数字页面链接),get_feed_link(文章Feed链接),get_post_comments_feed_link(评论Feed链接),get_author_feed_link(按作者文章Feed链接),get_category_feed_link(按分类Feed链接),get_tag_feed_link(按标签Feed链接),get_search_comments_feed_link(搜索评论Feed链接);在上述函数的最后,都有一个类似的函数:apply_filters('get_pagenum_link', $result); 而我们需要将相应页面函数修改为:apply_filters('get_pagenum_link', $result).'/'; 这个办法最为直接,将你希望出现反斜杠的页面所对应的函数修改好保存即可。
wordpress用插件实现新建页面的分页,所有分页显示内容一样怎么办...
展开全部 WordPress长文章分页的操作步骤: 第一步:进入WordPress网站后台,在外观下找到“编辑”选项,然后找到文章页面模块single.php,在single.php中找到下面的代码 第二步:找到上面的代码之后,在其下方添加wordpress自带的分页功能函数代码: 第三步:第二步的代码可以实现简单的分页效果,如果你想让分页按钮更加美观的话,可以将第二步的代码替换成下面的调用代码: '分页阅读:', 'after' => '', 'next_or_number' => 'next', 'previouspagelink' => '上一页', 'nextpagelink' => "")); ?> '', 'after' => '', 'next_or_number' => 'number', 'link_before' =>'', 'link_after'=>'')); ?> '', 'after' => '', 'next_or_number' => 'next', 'previouspagelink' => '', 'nextpagelink' => "下一页")); ?> 通过下面的CSS代码来控制分页按钮的显示样式,直接复制下面的CSS样式到style.css文件中,这样就可以实现下面的效果 /**页面分页**/ .fenye{text-align:center;margin:0px auto 10px;font-weight:bold} .fenye span{background-color:#DDDDDD;color:#fff;font-weight: bold;margin:0px 1px;padding:1px 6px;display:inline-block;text-decoration:none;border:1px solid #e0e0e0;} .fenye a{text-decoration:none;} .fenye a span{background-color:#F6F6E8;font-weight: normal;color: #000;text-decoration: none;} .fenye a:hover span{background-color:#DDDDDD;color: #fff;} 第四步:在文章中需要分页的位置插入分页代码【必须在代码文本模式下插入】 第五步:如果觉得每次使用分页代码比较麻烦,可以通过在编辑器上方添加一个“分页按钮”来使用,即在文章中需要分页的地方点一下“分页按钮”就会自动的添加分页代码。
【此步可做可不做】 1、找到 /wp-includes/class-wp-editor.php 文件。
查找 'wp_more', 标签:(在366行处) $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv' ), $editor_id); 2、在 'wp_more' 后添加 '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' ), $editor_id); 3、此时,你就可以在后台写文章及编辑文章页面的文本编辑器上看到一个跟 more 标签按钮相似的图标。
同样,在代码编辑器也会相应出现一个 nextpage 按钮。
第六步:消除分类后不同页面的文章的标题相同的问题,避免影响网站SEO优化。
在主题模板文件 header.php 找到类似 …… 代码,将其替换为如下代码。
— 第七步:实现分页功能后,会导致Feed页面的文章被分页,一般只显示第一页的内容,解决方法:打开 wp-includes 目录下的 query.php 文件,找到下面这行代码(大概在3578行) if ( strpos( $content,'' ) ) { 把它修改为下面这行代码。
if ( strpos( $content, '' ) && (!is_feed()) ) {
wordpress如何实现文章内容分页及标题修改
首页分页是好的么?如果是,去检查index.php的分页代码和category.php的分页代码有什么区别。
如果首页也不是好的,那么用WP-PageNavi分页插件,或者用分页代码实现。
http://zhidao.baidu.com/question/2116215421560188827.html这个是我前几天写的分页代码,一样可以用。
转载请注明出处51数据库 » wordpress 分页制作
-杨老师