【发布时间】:2013-11-12 21:38:36
【问题描述】:
所以我想做的是有一个 wordpress 内容区域,当点击链接时会显示下一篇文章。我有这个作为我的帖子查询
<?php
$args = array();
$lastposts = get_posts( $args );
foreach ( $lastposts as $post )
{
setup_postdata( $post );
$posts[] += $post->ID;
}
$current = array_search(get_the_ID(), $posts);
$prevID = $posts[$current-1];
$nextID = $posts[$current+1];
?>
然后我把这个作为分页链接
<?php if (!empty($prevID)) { ?>
<li class="previous">
<a class="panel" href="<?php echo get_permalink($prevID); ?>" title="<?php echo get_the_title($prevID); ?>">← Older</a>
</li>
<?php }
if (!empty($nextID)) { ?>
<li class="next">
<a class="panel" href="<?php echo get_permalink($nextID); ?>" title="<?php echo get_the_title($nextID); ?>">Newer →</a>
</li>
<?php } ?>
我不知道如何告诉帖子的内容(the_permalink、the_content)来显示下一个帖子。我的目标是添加某种过渡,但这并不像出现下一篇文章那么重要。有什么想法,有可能吗?
【问题讨论】:
-
感谢您的回答。不知道为什么有人会降级我的问题,但无论如何。这类似于我现在使用的滑块功能,问题是让 wordpress 识别下一张幻灯片应该包含下一篇文章的内容。我将尝试创建一个面具,然后隐藏 5 个元素。然后看看是否将 $nextID 参数添加到 wp_content 函数将起作用。如果有人知道更好的方法,请告诉我。
标签: javascript php jquery wordpress dynamic-data