【发布时间】:2015-03-12 19:17:10
【问题描述】:
我有一个简单的模板页面,我刚刚添加到我的网站,并且每个月都会手动添加新的时事通讯的部门。但是,当我收到很多时事通讯时,将要查看该页面的用户将不得不继续向下滚动才能找到时事通讯。
<?php get_header();?>
<div id="main" class="defaultContentWidth">
<div id="wrapper-row">
<div id="primary">
<div id="content">
<?php the_breadcrumb();?>
<h1 class="entry-title"><?php the_title();?></h1>
<?php if(have_posts()) :
while(have_posts()) : the_post();?>
<div class="newscont"><?php the_content();?></div>
<?php endwhile;
endif;?>
<div class="contnewslist">
<div class="newsblock">
<h2>NEWSLETTER 1</h2>
<i>December 01, 2014</i>
<p>This is the December edition of the newsletter. Featuring in this newsletter is ...</p>
<input type="submit" value="Download" id="download" class="newsdownload">
</div>
<div class="newsblock">
<h2>NEWSLETTER 2</h2>
<i>January 01, 2015</i>
<p>This is the January edition of the newsletter. Featuring in this newsletter is ...</p>
<input type="submit" value="Download" id="download" class="newsdownload">
</div>
</div>
</div>
</div>
</div>
</div>
<?php get_footer();?>
因此,我想知道如何在页面上添加基本的分页 'Previous 1 2 Next' 按钮,并将时事通讯的分区数量限制在每页大约五个,记住 这些不是帖子!
编辑 1
我需要知道如何计算 div 的数量,将其限制为每页 5 个 div,并根据通讯 div 的数量生成更多页面!
我想要的分页示例是 -
【问题讨论】:
-
我看到你已经标记了wordpress,没有插件可以做到这一点吗?到目前为止你尝试过什么?
-
@Billy 我发现了一些提供分页等的插件......但老实说,我发现的那些是基于分页帖子的,因此我强调我没有使用帖子!
-
来自 DB 或硬编码到 html 中的 div 在哪里?如果是数据库,那么 Google 上有很多教程
-
@Billy 它们被硬编码到 html 中,但是如果使用硬代码完成分页要困难得多,那么我也许可以考虑将其更改为 DB。
-
将所有 div 分组到一个容器中,并将溢出隐藏和空白设置为 no-wrap,然后每 5 个元素分组到另一个 div 中,该 div 将充当您的页面。使这些页面内联块与容器的宽度相同。然后,您可以根据它们需要在哪个页面上向左或向右动画块。然后在底部创建分页链接很容易,只要您跟踪它们所在的页面即可。
标签: php html wordpress pagination