2011-12-30 72 views
1
<?php 
/** 
* Template Name: Blog page 
* Description: The blog page 
*/ 
get_header(); ?> 


<?php 
$args = array('numberposts' => 3); 
$lastposts = get_posts($args); 
foreach($lastposts as $post) : setup_postdata($post); ?> 
<div class="postblog"> 
    <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1> 

    <span class="postdetails"> 
    <?php the_time ('j F, Y'); ?>&nbsp;&nbsp;&nbsp;<span class="bullet">&bull;</span>&nbsp;&nbsp;&nbsp;Posted in:&nbsp;<?php the_category(', '); ?> 
    </span> 

    <?php the_content(); ?> 

    <div class="fb"> 
    <?php if(function_exists("wpfblike")) echo wpfblike(); ?> 
    </div> 

    </div> 

<?php endforeach; ?> 


</div> 
<?php get_footer(); ?> 

每當我嘗試使用WP_Paginate或Pagenavi與此,它拒絕顯示,無論我嘗試使用我無法獲得頁面導航。我有5個帖子,只有三個正在顯示(根據上面的代碼),所以我怎樣才能到另外兩個?爲什麼頁面導航不起作用?

回答

1

您是否嘗試過使用next_posts_linksprevious_posts_links

<?php 
$page = (get_query_var('paged')) ? get_query_var('paged') : 1; 
query_posts("showposts=3&paged=$page"); 
?> 
<?php while (have_posts()) : the_post(); ?> 
// display your post 
<?php endwhile; ?> 
// display navigation 
<div class="navigation"> 
<div class="alignleft"><?php next_posts_link('&larr; Older Entries') ?></div> 
<div class="alignright"><?php previous_posts_link('Newer Entries &rarr;') ?></div> 
</div> 
+0

這確實有用,但是我怎麼得不到這些插件? – user1100887 2011-12-30 04:33:02

+0

你使用哪個wordpress版本? – Cyclonecode 2011-12-30 04:38:32

+0

最新的,3.3 – user1100887 2011-12-30 04:44:41