query_posts('category_name=新闻&showposts=1');
<?php while (have_posts()) : the_post(); ?>
<div>TOP NEWS <?php previous_post_link('%link', '>', TRUE) ; ?> </div>
<?php $row = get_post_meta(get_the_id(), 'video');?>
<?php echo $row[0]; ?>
<div class="post" id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink(); ?>"><h2><?php the_title(); ?></h2></a>
<h3>by <?php the_author(); ?></h3>
</div>
<?php the_content('Read more »'); ?>
<?php previous_post_link('%link', 'Prev post in category', TRUE); ?>
<?php endwhile;?>
<?php wp_reset_query();?>
<?php endif;?>
我在我的静态页面中使用这些代码。 当我单击 previous_post_link 时,它会转到单个页面以显示帖子。 我需要在同一个静态页面中显示该帖子。 有人有什么想法吗?
最佳答案
默认情况下,这就是 previous_post_link 的作用。如果您想在同一页面上加载下一篇文章,那么您将需要研究 AJAX。听起来很吓人,但与 jQuery 结合使用时实际上非常简单。看一下 jQuery 中的 .get() 函数。
您需要这样做,以便单击上一个按钮向 jQuery 发送一个 get 请求,并用该页面的内容填充 div。
关于wordpress - 前一篇文章链接问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5990004/