【问题标题】:Why does page navigation not work here?为什么页面导航在这里不起作用?
【发布时间】:2011-12-30 04:13:43
【问题描述】:
    <?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 个帖子,只有 3 个在显示(根据上面的代码),那么我该如何找到另外两个?

【问题讨论】:

    标签: wordpress navigation categories posts


    【解决方案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>
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-06
    • 2013-05-16
    • 2019-02-10
    • 2017-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多