让Into-The-Ocean适应pagenavi
如果使用wp_pagenavi这个插件,可以实现WordPress的翻页,直观方便快捷。但Into-The-Ocean的首页是如此调用日志的:
1 2 3 4 5 6 7 8 9 10 11 12 | /?php query_posts('showposts=4'); ?/ /?php $my_query = new WP_Query('showposts=1'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID;?/ <h2><a href="/?php the_permalink(); ?/">/?php the_title(); ?/</a></h2> <span class="latestdate">Posted: /?php the_time('F jS, Y'); ?/</span> <span class="category">Filed Under: /?php the_category(', ') ?/</span> /?php the_content(); ?/ /?php endwhile; ?/ |
可见它固定了从最后一篇日志开始显示,总共4篇。哪怕翻到page2,page3,它还是一样的输出。而我们要得效果是,翻到第二页,last_post和recent_post也跟上一页延续;而且每页显示的日志数最好由后台控制,不用每次需要修改theme文件。
将上面的代码转换为如下:
1 2 3 4 5 6 7 8 9 10 | /?php query_posts('showposts=4'); ?/ /?php if (have_posts()) : the_post(); $do_not_duplicate=$post->ID; ?/ <h2><a href="/?php the_permalink(); ?/">/?php the_title(); ?/</a></h2> <span class="latestdate">Posted: /?php the_time('F jS, Y'); ?/</span> <span class="category">Filed Under: /?php the_category(', ') ?/</span> /?php the_content(); ?/ /?php endif; ?/ |
请注意将”/?”替换成”<?”、”?/”替换成”?>”。
================这条分割线很美=====================
WordPress Theme Into-The-Ocean fixes its index page. Even we change to Page 2, Page 3…, nothing will happen. And the number of posts is limited by ‘showposts=4’. In this case, the pagenavi, a nice WordPress plugin, will be of no effect.
Obviously, this is not we want. We’d like get changing page according to the previous one and defining the output number at the administration page.
To achieve above we should display following code in the index.php of Into-The-Ocean:
1 2 3 4 5 6 7 8 9 10 11 12 | /?php query_posts('showposts=4'); ?/ /?php $my_query = new WP_Query('showposts=1'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID;?/ <h2><a href="/?php the_permalink(); ?/">/?php the_title(); ?/</a></h2> <span class="latestdate">Posted: /?php the_time('F jS, Y'); ?/</span> <span class="category">Filed Under: /?php the_category(', ') ?/</span> /?php the_content(); ?/ /?php endwhile; ?/ |
by
1 2 3 4 5 6 7 8 9 10 | /?php query_posts('showposts=4'); ?/ /?php if (have_posts()) : the_post(); $do_not_duplicate=$post->ID; ?/ <h2><a href="/?php the_permalink(); ?/">/?php the_title(); ?/</a></h2> <span class="latestdate">Posted: /?php the_time('F jS, Y'); ?/</span> <span class="category">Filed Under: /?php the_category(', ') ?/</span> /?php the_content(); ?/ /?php endif; ?/ |
Make sure change “/?” to “<?” and “?/” to “?>”.
没弄成:www.xunnage.com
啥意思?有啥问题。