<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Wordpress pagination Archives - Tricky Enough</title>
	<atom:link href="https://www.trickyenough.com/tag/wordpress-pagination/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.trickyenough.com/tag/wordpress-pagination/</link>
	<description>Explore and Share the Tech</description>
	<lastBuildDate>Thu, 07 Nov 2024 08:48:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://www.trickyenough.com/wp-content/uploads/2021/05/favicon-32x32-1.png</url>
	<title>Wordpress pagination Archives - Tricky Enough</title>
	<link>https://www.trickyenough.com/tag/wordpress-pagination/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">100835972</site>	<item>
		<title>Step by Step Guide for Category Pagination in WordPress</title>
		<link>https://www.trickyenough.com/pagination-in-wordpress/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pagination-in-wordpress</link>
					<comments>https://www.trickyenough.com/pagination-in-wordpress/#comments</comments>
		
		<dc:creator><![CDATA[Nathan Beers]]></dc:creator>
		<pubDate>Sun, 25 Mar 2018 19:47:54 +0000</pubDate>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Wordpress pagination]]></category>
		<category><![CDATA[WordPress website]]></category>
		<guid isPermaLink="false">https://www.trickyenough.com/?p=5778</guid>

					<description><![CDATA[<p>WordPress provides an inbuilt feature used to navigate through posts. Developers of themes can make use of numbered pagination of straightforward links to mark or distinguish the next page or the previous page in a sequence. WordPress can be able to divide one post or multiple posts into various pages so that “paged” navigation can...</p>
<p>The post <a href="https://www.trickyenough.com/pagination-in-wordpress/">Step by Step Guide for Category Pagination in WordPress</a> appeared first on <a href="https://www.trickyenough.com">Tricky Enough</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>WordPress provides an inbuilt feature used to navigate through posts. Developers of themes can make use of <strong>numbered pagination</strong> of straightforward links to mark or distinguish the next page or the previous page in a sequence.</p>



<p>WordPress can be able to divide one post or multiple posts into various pages so that “paged” navigation can be enabled. The number of posts that will comprise each page on the Reading Screen can be set using:</p>



<h2 class="wp-block-heading">Wp-admin &gt; Settings &gt; Reading</h2>


<div class="wp-block-image">
<figure class="aligncenter"><img fetchpriority="high" decoding="async" width="538" height="266" src="https://www.trickyenough.com/wp-content/uploads/2018/03/2.png" alt="" class="wp-image-5780" srcset="https://www.trickyenough.com/wp-content/uploads/2018/03/2.png 538w, https://www.trickyenough.com/wp-content/uploads/2018/03/2-300x148.png 300w" sizes="(max-width: 538px) 100vw, 538px" /><figcaption class="wp-element-caption">Image Credits: Screenshot taken from the website</figcaption></figure></div>


<p>Except it is overridden by your theme, WordPress will make use of its default option to decide the number of blog posts present on one page. An example where WordPress might decide to override this value is when a custom query is being used.</p>



<h2 class="wp-block-heading">WordPress makes use of pagination when:</h2>



<ul class="wp-block-list">
<li>There are too many posts and all cannot fit on one page;</li>



<li>Dividing longer posts manually by using <em>&lt;!&#8211;nextpage&#8211;></em></li>
</ul>


<div class="wp-block-image">
<figure class="aligncenter"><img decoding="async" width="1258" height="510" src="https://www.trickyenough.com/wp-content/uploads/2018/03/3.png" alt="" class="wp-image-5781" srcset="https://www.trickyenough.com/wp-content/uploads/2018/03/3.png 1258w, https://www.trickyenough.com/wp-content/uploads/2018/03/3-300x122.png 300w, https://www.trickyenough.com/wp-content/uploads/2018/03/3-768x311.png 768w, https://www.trickyenough.com/wp-content/uploads/2018/03/3-1024x415.png 1024w" sizes="(max-width: 1258px) 100vw, 1258px" /><figcaption class="wp-element-caption">Image Credits: Screenshot taken from the website</figcaption></figure></div>


<p>This is the most popular use of pagination in WordPress sites. Long lists of posts are broken into different pages. Normally, WordPress can only show 10 posts per page and it doesn&#8217;t matter if you&#8217;re viewing an archive or a default index page. This, however, can be changed using:</p>



<p>Admin &gt; Settings &gt; Reading</p>



<h2 class="wp-block-heading">Displaying Pagination Links</h2>


<div class="wp-block-image">
<figure class="aligncenter"><img decoding="async" width="552" height="295" src="https://www.trickyenough.com/wp-content/uploads/2018/03/4.png" alt="" class="wp-image-5782" srcset="https://www.trickyenough.com/wp-content/uploads/2018/03/4.png 552w, https://www.trickyenough.com/wp-content/uploads/2018/03/4-300x160.png 300w" sizes="(max-width: 552px) 100vw, 552px" /><figcaption class="wp-element-caption">Image Credits: Screenshot taken from the website</figcaption></figure></div>


<p>WordPress is blessed with different functions for showing links in various pages in your loop. However, some of these functions can only be used in unique contexts. Single post pages and archive pages possess different functions.</p>



<h3 class="wp-block-heading">Simple Pagination</h3>


<div class="wp-block-image">
<figure class="aligncenter"><img decoding="async" width="555" height="212" src="https://www.trickyenough.com/wp-content/uploads/2018/03/5.png" alt="" class="wp-image-5783" srcset="https://www.trickyenough.com/wp-content/uploads/2018/03/5.png 555w, https://www.trickyenough.com/wp-content/uploads/2018/03/5-300x115.png 300w" sizes="(max-width: 555px) 100vw, 555px" /><figcaption class="wp-element-caption">Image Credits: Screenshot taken from the website</figcaption></figure></div>


<p>There are different methods available but one of the simplest is <em>posts_nav_link()</em>. All you have to do is place the function in your template immediately where the loop ends. This will create links to the next page and previous page (if applicable) of posts. This function is suitable for <strong>WordPress Theme Development</strong> with simple pagination requirements.</p>



<h3 class="wp-block-heading">Numerical Pagination</h3>


<div class="wp-block-image">
<figure class="aligncenter"><img decoding="async" width="417" height="268" src="https://www.trickyenough.com/wp-content/uploads/2018/03/6.png" alt="" class="wp-image-5784" srcset="https://www.trickyenough.com/wp-content/uploads/2018/03/6.png 417w, https://www.trickyenough.com/wp-content/uploads/2018/03/6-300x193.png 300w" sizes="(max-width: 417px) 100vw, 417px" /><figcaption class="wp-element-caption">Image Credits: Screenshot taken from the website</figcaption></figure></div>


<p>When multiple pages are present, it will be more-ideal to create a list of page numbers so it will be easy to navigate. With the list of page numbers, there won&#8217;t be any need to repeatedly click the next or previous posts. There are several functions provided for numerical pagination lists.</p>



<p><strong>Suggested:</strong></p>



<p><a href="https://www.trickyenough.com/why-use-wordpress/" target="_blank" rel="noopener noreferrer">Why Use WordPress for your Website</a>?</p>



<p>And</p>



<p><a href="https://www.trickyenough.com/how-secure-is-wordpress/" target="_blank" rel="noopener noreferrer">How Secure is WordPress</a>?</p>



<ol start="4" class="wp-block-list">
<li>a) <strong>For WordPress 4.1+</strong></li>
</ol>



<p>To ensure a more extensive pagination option, you can make use of <em>the_posts_pagination()</em> for WordPress 4.1 and all other higher versions. This will ensure that links to previous and next pages of posts are provided.</p>



<ol start="4" class="wp-block-list">
<li>b) <strong>For WordPress before the 4.1 Version</strong></li>
</ol>



<p>Use <em>paginate_links()</em> if you want your pagination to support WordPress versions before 4.1.</p>



<h2 class="wp-block-heading">Pagination Between Single Posts</h2>


<div class="wp-block-image">
<figure class="aligncenter"><img decoding="async" width="1196" height="399" src="https://www.trickyenough.com/wp-content/uploads/2018/03/7.jpg" alt="" class="wp-image-5785" srcset="https://www.trickyenough.com/wp-content/uploads/2018/03/7.jpg 1196w, https://www.trickyenough.com/wp-content/uploads/2018/03/7-300x100.jpg 300w, https://www.trickyenough.com/wp-content/uploads/2018/03/7-768x256.jpg 768w, https://www.trickyenough.com/wp-content/uploads/2018/03/7-1024x342.jpg 1024w" sizes="(max-width: 1196px) 100vw, 1196px" /><figcaption class="wp-element-caption">Image Credits: Screenshot taken from the website</figcaption></figure></div>


<p>The previous functions are to be utilized on archive and index pages. To view a single blog post, you must make use of <em>prev_post_link</em> and <em>next_post_link. </em>You&#8217;ll have to place the below functions at the end of the loop on your single.php.</p>



<p>1 | previous_post_link();</p>



<p>2 | next_post_link();</p>



<h2 class="wp-block-heading">Pagination Within a Post<img decoding="async" class="aligncenter size-full wp-image-5786" src="https://www.trickyenough.com/wp-content/uploads/2018/03/8.jpg" alt="" width="880" height="390" srcset="https://www.trickyenough.com/wp-content/uploads/2018/03/8.jpg 880w, https://www.trickyenough.com/wp-content/uploads/2018/03/8-300x133.jpg 300w, https://www.trickyenough.com/wp-content/uploads/2018/03/8-768x340.jpg 768w" sizes="(max-width: 880px) 100vw, 880px" /></h2>



<p>WordPress makes a tag available. This tag can be placed in post content so that pagination for that post can be enabled.</p>



<p><em>1&lt;!&#8211;nextpage&#8211;&gt;</em></p>



<p>If you&#8217;re making use of the tag in the content, you have to make sure that the <em>wp_link_pages</em> functions is arranged in your single.php template inside your loop.</p>



<p>1 | &lt;?php if ( have_posts() ) : ?&gt;</p>



<p>2 |</p>



<p>3 |&nbsp;&nbsp; &lt;!&#8211; Start of the main loop. &#8211;&gt;</p>



<p>4 |&nbsp;&nbsp; &lt;?php while ( have_posts() ) : the_post(); ?&gt;</p>



<p>5 |</p>



<p>6 |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;?php the_content(); ?&gt;</p>



<p>7 |</p>



<p>8 |&nbsp;&nbsp;&nbsp;&nbsp; &lt;?php wp_link_pages(); ?&gt;</p>



<p>9 |</p>



<p>10 |&nbsp;&nbsp;&nbsp; &lt;?php endwhile; ?&gt;</p>



<p>11 |</p>



<p>12 | &lt;?php endif; ?&gt;</p>



<p>&nbsp;</p>



<p><strong>Category Pagination in WordPress</strong></p>


<div class="wp-block-image">
<figure class="aligncenter"><img decoding="async" width="823" height="514" src="https://www.trickyenough.com/wp-content/uploads/2018/03/9.png" alt="" class="wp-image-5787" srcset="https://www.trickyenough.com/wp-content/uploads/2018/03/9.png 823w, https://www.trickyenough.com/wp-content/uploads/2018/03/9-300x187.png 300w, https://www.trickyenough.com/wp-content/uploads/2018/03/9-768x480.png 768w" sizes="(max-width: 823px) 100vw, 823px" /><figcaption class="wp-element-caption">Image Credits: Screenshot taken from the website</figcaption></figure></div>


<p></p>



<p><strong>Category pagination in WordPress</strong> can honestly be a bit dicey in its execution. In this post, we&#8217;ll assume that you&#8217;re establishing a custom category page (almost like category.php) in your theme file.</p>



<p>As we commence, we must establish the current category of the page. This would differ when considering the category the user clicked on to arrive on this page. To find out the current category, put the following code in your code editor:</p>



<p>1 | &lt;?php</p>



<p>2 |&nbsp; $currCat = get_category(get_query_var(&#8216;cat&#8217;));</p>



<p>3 | $cat_name = $currCat-&gt;name;</p>



<p>4 | $cat_id&nbsp;&nbsp; = get_cat_ID( $cat_name );</p>



<p>5 | ?&gt;</p>



<p>We now have the current category saved in <em>$cat_id</em>. We&#8217;ll now start with the second part which entails establishing unique arguments for your loop and the real loop. It should be noted that putting an offset number into the loop will break it.</p>



<p>1 | &lt;?php</p>



<p>2 |&nbsp; $paged = (get_query_var(&#8216;paged&#8217;)) ? get_query_var(&#8216;paged&#8217;) : 1;</p>



<p>3 |&nbsp; $temp = $wp_query;</p>



<p>4 | $wp_query = null;</p>



<p>5 |&nbsp; $wp_query = new WP_Query();</p>



<p>6 |&nbsp; $wp_query-&gt;query(&#8216;showposts=10&amp;post_type=post&amp;paged=&#8217;.$paged.&#8217;&amp;cat=&#8217;.$cat_id);</p>



<p>7 |&nbsp; while ($wp_query-&gt;have_posts()) : $wp_query-&gt;the_post();</p>



<p>8 | ?&gt;</p>



<p>After the code, there should be an opening to put in your HTML for your loop&#8217;s output. It should be like this:</p>



<p>1 | &lt;div class=&#8221;module-container&#8221;&gt;;</p>



<p>2 |&nbsp;&nbsp; &lt;div class=&#8221;content&#8221;&gt;;</p>



<p>3 |&nbsp;&nbsp; &lt;span class=&#8221;author&#8221;&gt;&lt;?php the_author(); ?&gt;&lt;/span&gt;</p>



<p>4 |&nbsp;&nbsp;&nbsp; &lt;?php the_content(); ?&gt;</p>



<p>5 |&nbsp; &lt;/div&gt;</p>



<p>6 | &lt;/div&gt;</p>



<p>The above is a random example of what your code might look like. It definitely will be more complex than the example.</p>



<p>End the loop once you&#8217;re done with the HTML/PHP.</p>



<p>1 | &lt;?php endwhile; ?&gt;</p>



<p>After ending the loop, the final step should be started. This step will bring everything together and ultimately insert the pagination links to the page. Wrapping this code in a div isn&#8217;t compulsory, but I decided to do it anyway. You can also change the <em>prev_text</em> and <em>next_text</em> to anything of your preference.</p>



<p>1 | &lt;?php</p>



<p>2 |&nbsp; global $wp_query;</p>



<p>3 |</p>



<p>4 |&nbsp; $big = 999999999; // need an unlikely integer</p>



<p>5 |&nbsp; echo &#8216;&lt;div class=&#8221;paginate-links&#8221;&gt;&#8217;;</p>



<p>6 |&nbsp;&nbsp; echo paginate_links( array(</p>



<p>7 |&nbsp;&nbsp; &#8216;base&#8217; =&gt; str_replace( $big, &#8216;%#%&#8217;, esc_url( get_pagenum_link( $big ) ) ),</p>



<p>8 |&nbsp;&nbsp;&nbsp; &#8216;format&#8217; =&gt; &#8216;?paged=%#%&#8217;,</p>



<p>9 |&nbsp;&nbsp;&nbsp; &#8216;prev_text&#8217; =&gt; __(&#8216;&lt;&lt;&#8216;),</p>



<p>10 |&nbsp;&nbsp;&nbsp; &#8216;next_text&#8217; =&gt; __(&#8216;&gt;&gt;&#8217;),</p>



<p>11 |&nbsp;&nbsp;&nbsp; &#8216;current&#8217; =&gt; max( 1, get_query_var(&#8216;paged&#8217;) ),</p>



<p>12 |&nbsp;&nbsp; &#8216;total&#8217; =&gt; $wp_query-&gt;max_num_pages</p>



<p>13 |&nbsp;&nbsp; ) );</p>



<p>14 |&nbsp; echo &#8216;&lt;/div&gt;&#8217;;</p>



<p>15 | ?&gt;</p>



<p>With this, you&#8217;ve put pagination into your custom page.</p>
<p>The post <a href="https://www.trickyenough.com/pagination-in-wordpress/">Step by Step Guide for Category Pagination in WordPress</a> appeared first on <a href="https://www.trickyenough.com">Tricky Enough</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.trickyenough.com/pagination-in-wordpress/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">5778</post-id>	</item>
	</channel>
</rss>
