2013-02-01 37 views
0

我使用WordPress 3.4 = 5,其中我已經使用代碼來獲得職位,但分頁不工作這一點,請幫助WordPress的3.5分頁

$posts = get_posts('category='.$subcatid.'&orderby=rand&numberposts=4'); 
foreach($posts as $post) { ?> 
<h2> 
    <a href="<?php the_permalink() ?>" target="_parent"><?php the_title(); ?></a> 
</h2> 
<p><?php //echo $post->post_content; ?></p> 
<p><?php echo get_post_meta($post->ID, 'Address', true); ?></p> 
<hr style="margin-left:0px; margin-right:0px; margin-bottom:15px; margin-top:15px;" /> 
<?php } ?> 

回答

0

分頁不get_posts工作()。因爲你修改了正常循環iter。

+0

確定感謝信息 – user1713694

0

你能做到這樣,並使用WP-pagenavi插件這個

<?php get_query_var('paged'); 
         query_posts('cat='.$subcatid.'&posts_per_page=2'); 
         if (have_posts()) : while (have_posts()) : the_post(); 
         ?> 

         <h2> 
     <a href="<?php the_permalink() ?>" target="_parent"><?php the_title(); ?></a> 
    </h2> 

    <p><?php echo get_post_meta($post->ID, 'Address', true); ?></p> 
    <hr style="margin-left:0px; margin-right:0px; margin-bottom:15px; margin-top:15px;" /> 
         <?php endwhile; 
         if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?> 
    <?php     
         endif; ?> 
+0

的偉大工程,感謝名單 – user1713694