使用WP链接页面功能

时间:2016-02-04 07:46:49

标签: php wordpress

我的一个网站包含一篇总共10页的文章。当用户点击底部的“下一步”链接时,他应该转到同一篇文章的下一页而不是下一篇文章。正如你在这里看到的那样:

http://www.breakingcoffee.com/10-most-shocking-celebrity-deaths-of-all-time/

我将确切的代码复制到其他网站,但不幸的是,“下一个”链接根本没有显示,而是显示主题本身的两个箭头,如您所见:

http://www.directexpose.com/10-stars-that-have-been-arrested/

以下是我在两个网站上插入的代码:

<div style="width:100%;text-align:center">Advertisement</div>
<?php echo do_shortcode("[pro_ad_display_adzone id=2165]"); ?>
<br/><br/>
                                                                                                                                                                                                                <?php the_content(); ?>
 
<br/>
<div style="width:100%;text-align:center">Advertisement</div>
<?php echo do_shortcode("[pro_ad_display_adzone id=2167]"); ?>
 
<h1>
<div style="text-align: center;max-width:728px;width:100%;margin: 0 auto" class="page-link-next-prev">
<?php
global $page, $pages;
 
// If the current page equals the last page
if ($page == count($page)):
 
  $previous_post = get_previous_post();
  // Then spit out the next link
  ?>
  <a href="<?php echo get_permalink( $previous_post->ID ); ?>"><span style="float:left;" class="meta-item"></span></a>
<?php
// End the if statement
endif;
 
wp_link_pages( array( 'before' => '',
'after' => '', 'previouspagelink' => '<span style="float:left;" class="meta-item">Previous</span>', 'nextpagelink' => '',
'next_or_number' => 'next' ) );
 
 
// If the current page is first page
if ($page == count($pages)):
 
  $next_post = get_next_post();
  // Then spit out the next link
  ?>
  <a href="<?php echo get_permalink( $next_post->ID ); ?>"><span style="float:right;" class="meta-item">Next</span></a>
<br/>
<?php
// End the if statement
endif;
 
wp_link_pages( array( 'before' => '', 'after' => '', 'previouspagelink' => '',
'nextpagelink' => '<span style="float:right;text-decoration: underline;font-weight: bold;" class="meta-item">Next>></span>', 'next_or_number' => 'next' ) );
 
 
?>
</div>
<div class="mob-clear-fix"></div>
</h1>
 

有人知道如何在第二个网站上插入与该功能相同的“下一个”链接?

由于

1 个答案:

答案 0 :(得分:-1)

希望这可以帮助你通过wpbeginner发布http://www.wpbeginner.com/wp-tutorials/how-to-split-wordpress-posts-into-multiple-pages/关于如何在WordPress中将帖子分成多个页面的信息。

相关问题