Reputation: 47
I have a simple template page which I just added to my website, and will be manually adding in divisions for a new newsletter every month. However, when I get quite a few newsletters, users who will be viewing the page will have to keep scrolling down to find a newsletter.
<?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();?>
Therefore I want to know how I could add basic pagination 'Previous 1 2 Next' buttons onto the page and limit the amount of divisions of newsletters to about five per page, baring in mind these are not posts!
EDIT 1
I need to know how to count the amount of divs there are, limit it to five divs per page and generate more pages depending on how many newsletter divs there are!
An example of the sort of paginating I would like is -
Upvotes: 0
Views: 1114
Reputation: 2448
I think the best way to go if they are on the DB would be with PHP and Jquery pagination. let's say for example that you have 100 newsletters, you could do it with just php pagination like this tutorial PHP Tutsplus tutorial on pagination and split it into 5's, Go this way if the newsletters are large in size. The downside is a call to the server for each page change. If the newsletters are fairly small then mix jquery in, have the php count the total, pass over the first 15 or 20 and have jquery split them up in to 5's, with maybe an ajax call when page 5 is loaded to fetch the next 15.jquery would be able to handle that and add on onclick when page 6 is requested to update the div seemlessly Jquery pagination pluhgins can be found here, sitepoint
Upvotes: 1