0
    <?php if (is_single()) {?>
    <div class="post-prenex">
<div class="alignleft">
<?php previous_post('&laquo; &laquo; %',
 'Previous Post ', 'no'); ?>
</div>
<?php ?>
<div class="alignright">
<?php next_post('% &raquo; &raquo; ',
 'Next Post ', 'no'); ?>
</div>
</div> 

<?php }?>

大家好,我尝试了简单的插件作为下一篇和上一篇文章。在下一个和上一个帖子中工作正常。但是帖子中的内容消失了。我不知道我做错了什么。注意:我没有编辑我通过the_content的add_action尝试的single.php 文件

任何人指出问题并给出解决方案都非常感谢。

4

1 回答 1

1

我看到的一些问题:

  • previous_post() 和 next_post() 已弃用
  • 使用 the_content 操作时,函数必须返回实际内容

例子

function mycontent( $content ) {
   $output = '';
   // add something to output
   return $content.$output;  //return content with output
}
add_action( 'the_content', 'mycontent' );
  • 帖子/页面导航标签是模板标签,应该在模板文件中使用
于 2013-05-20T18:32:07.903 回答