我使用引导框架创建了一个wordpress主题,当用户单击帖子时,弹出窗口并显示帖子的内容,而不是转到单个帖子页面。
我的问题是我需要添加一个下一个/上一个按钮,以便当用户单击它时,模式将关闭,而另一个将弹出下一个帖子的内容。
这是我的代码:
content.php
<a href="#myModal-<?php the_ID(); ?>" data-toggle="modal" class="clickme readmore text-right">Read more</a>
<div id="myModal-<?php the_ID(); ?>" class="modal fade"><?php include 'popup-modal.php'; ?> </div>
popup-modal.php
<div class="modal-dialog">
<div class="modal-content">
POST CONTENT HERE.......
<div class="nav-links">
<div class="nav-previous">
<a href="#" rel="prev" data-dismiss="modal" data-toggle="modal"></a>
</div>
<div class="nav-next">
<a href="#" rel="next" data-dismiss="modal" data-toggle="modal"></a>
</div>
</div>
</div>
</div>
现在,我不确定要在导航链接的href上放置什么内容,因此我可以调用下一个帖子并将其显示在模式中。我希望有人可以帮助我。
这是我的解决方案:
<?php $next_post = get_adjacent_post(false,'',false);?>
<?php $previous_post = get_adjacent_post(false,'',true);?>
然后,导航输出:
<div class="navigation row">
<div class="col-md-6">
<?php if($next_post->ID != ''): ?>
<a href="#myModal-<?php echo $next_post->ID; ?>" data-toggle="modal" >
<button type="button" class="btn btn-default m-t-30">Previous</button>
</a>
<?php endif; ?>
</div>
<div class="col-md-6">
<?php if($previous_post->ID != ''): ?>
<a href="#myModal-<?php echo $previous_post->ID; ?>" data-toggle="modal" >
<button type="button" class="btn btn-default m-t-30">Next</button>
</a>
<?php endif; ?>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句