Note that there are some explanatory texts on larger screens.

plurals
  1. POForeach pagination
    text
    copied!<p>I am looking for help in how to paginate my foreach output. I've looked at other questions and answers and cannot find a solution that works for me or that I can figure out on my own. Right now my code, which is below, outputs everything into table rows. My problem, of course, is that it dumps all data on a single page -- hence the reason I want pagination. I want to paginate for every 11 items on the page. The page is a magazine archive, and there are 11 issues pear year -- so every page is equal to 1 year of our magazine. The first page should host issues 1-11 and page two should host issues 12 through 22, etc. We have 10 years worth of magazine issues. Any help would be greatly appreciated. Thank you!</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;?php $col = 0; ?&gt; &lt;?php foreach (get_terms('term') as $cat) : ?&gt; &lt;?php if ($col &gt; 0 &amp;&amp; $col % 3 == 0): ?&gt; &lt;/tr&gt; &lt;tr&gt; &lt;?php endif; ?&gt; &lt;?php $col++; ?&gt; &lt;td&gt; &lt;a href="&lt;?php echo get_term_link($cat-&gt;slug, 'term'); ?&gt;"&gt;&lt;strong&gt;&lt;?php echo $cat-&gt;name; ?&gt;&lt;/strong&gt;&lt;/a&gt;&lt;br&gt; &lt;em&gt;&lt;a href="&lt;?php echo get_term_link($cat-&gt;slug, 'term'); ?&gt;"&gt;&lt;?php echo $cat-&gt;description; ?&gt;&lt;/a&gt;&lt;/em&gt;&lt;br&gt; &lt;a href="&lt;?php echo get_term_link($cat-&gt;slug, 'term'); ?&gt;"&gt;&lt;img src="&lt;?php echo z_taxonomy_image_url($cat-&gt;term_id); ?&gt;" /&gt;&lt;/a&gt; &lt;/td&gt; &lt;?php endforeach; ?&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload