<?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>WP Engineer &#187; Pagination</title> <atom:link href="http://wpengineer.com/tag/pagination/feed/" rel="self" type="application/rss+xml" /><link>http://wpengineer.com</link> <description>WordPress News, Hacks, Tipps, Tutorials, Plugins and Themes</description> <lastBuildDate>Wed, 28 Jul 2010 13:37:05 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=1816</generator> <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /> <item><title>Hide The Comment Pagination</title><link>http://wpengineer.com/hide-the-comment-pagination/</link> <comments>http://wpengineer.com/hide-the-comment-pagination/#comments</comments> <pubDate>Fri, 03 Jul 2009 09:25:45 +0000</pubDate> <dc:creator>Michael</dc:creator> <category><![CDATA[WordPress Hacks]]></category> <category><![CDATA[WordPress Themes]]></category> <category><![CDATA[Pagination]]></category> <category><![CDATA[WordPress]]></category><guid
isPermaLink="false">http://wpengineer.com/?p=1420</guid> <description><![CDATA[Ever since version 2.7 WordPress offers the option to adjust the number of comments on each page. From SEO's perspective, this is not very smart, as there were many articles and discussions about this topic in the past. If you turn off the comment pagination, the empty HTML fragment is still in the source code [...]]]></description> <content:encoded><![CDATA[<p>Ever since version 2.7 WordPress offers the option to adjust the number of comments on each page. From SEO's perspective, this is not very smart, as there were many articles and discussions about this topic in the past. If you turn off the comment pagination, the empty HTML fragment is still in the source code of the page.<br
/> <span
id="more-1420"></span><br
/> Unfortunately, the classes that respond with CSS are the same as those from the normal page and post pagination.<br
/> If you have a theme in which the outer container of pagination has a frame or a background color, then you can see the empty container. Here are 2 screenshots with and without activated comment pagination to illustrate what I mean:</p><p><img
class="aligncenter size-full wp-image-1422" title="Comment Pagination" src="http://wpengineer.com/blog/wp-content/uploads/comment-pagination.jpg" alt="Comment Pagination" width="373" height="39" /><br
/> <img
class="aligncenter size-full wp-image-1423" title="Empty Comment Pagination" src="http://wpengineer.com/blog/wp-content/uploads/empty-comment-pagination.jpg" alt="Empty Comment Pagination" width="373" height="39" /></p><p>Another annoyance would be if <code>.pagination</code> has a margin-bottom, which would also have a negative effect on the layout. What can you do about it?</p><p>WordPress stores the setting of the comment pagination in the database table options under page_comments. Value 1 means on, value 0 means off. By doing so you can hide the pagination in <strong>comments.php</strong> if it is not turned on:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'page_comments'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;div class=&quot;navigation&quot;&gt;
		&lt;div class=&quot;alignleft&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> previous_comments_link<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/div&gt;
		&lt;div class=&quot;alignright&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> next_comments_link<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/div&gt;
	&lt;/div&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div><p>The query checks whether the comment pagination is set to (1) and displays the navigation. If it is set to (0) it will not display the navigation. On the other hand, if it is turned off, WordPress doesn't need to execute the two functions <strong>previous_comments_link()</strong> and <strong>next_comments_link()</strong>.<br
/><hr
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/comment-pagination-and-reply-depth-in-wordpress-27/" rel="bookmark" title="Permanent Link: Comment Pagination And Reply Depth In WordPress 2.7" class="liinternal">Comment Pagination And Reply Depth In WordPress 2.7</a></li><li><a
href="http://wpengineer.com/correct-pagination-with-get_posts/" rel="bookmark" title="Permanent Link: Correct Pagination with get_posts" class="liinternal">Correct Pagination with get_posts</a></li><li><a
href="http://wpengineer.com/disable-html-editor-wordpress/" rel="bookmark" title="Permanent Link: Disable HTML Editor In WordPress" class="liinternal">Disable HTML Editor In WordPress</a></li><li><a
href="http://wpengineer.com/comment-ping-count/" rel="bookmark" title="Permanent Link: Comment And Ping Count In WordPress 2.7" class="liinternal">Comment And Ping Count In WordPress 2.7</a></li><li><a
href="http://wpengineer.com/flattr-button-4-wordpress-without-a-plugin/" rel="bookmark" title="Permanent Link: Flattr Button for WordPress without a Plugin" class="liinternal">Flattr Button for WordPress without a Plugin</a></li></ul><hr
/><p><img
style="float:left;" src="http://wpengineer.com/favicon.ico" alt="WP Engineer Favicon"/> Thanks for subscribing our feed! <a
href="http://buysellads.com/buy/detail/3646/" class="liexternal">Sponsor the WP Engineer Blog</a> and get your brand in front of several hundred users per day!<br
/> &copy; <a
href="http://wpengineer.com/" class="liinternal">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p> ]]></content:encoded> <wfw:commentRss>http://wpengineer.com/hide-the-comment-pagination/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Correct Pagination with get_posts</title><link>http://wpengineer.com/correct-pagination-with-get_posts/</link> <comments>http://wpengineer.com/correct-pagination-with-get_posts/#comments</comments> <pubDate>Thu, 28 May 2009 22:36:29 +0000</pubDate> <dc:creator>Michael</dc:creator> <category><![CDATA[WordPress Hacks]]></category> <category><![CDATA[get_posts]]></category> <category><![CDATA[hack]]></category> <category><![CDATA[Pagination]]></category> <category><![CDATA[WordPress]]></category><guid
isPermaLink="false">http://wpengineer.com/?p=1263</guid> <description><![CDATA[If you like to show your posts a little bit different on your homepage or category page. For example having a different amount of posts showing on these pages, as it is set in your admin, you will get a problem with the pagination function. Because WordPress and several paging Plugins use $wp_query->max_num_pages. max_num_pages is [...]]]></description> <content:encoded><![CDATA[<p>If you like to show your posts a little bit different on your homepage or category page. For example having a different amount of posts showing on these pages, as it is set in your admin, you will get a problem with the pagination function. Because WordPress and several paging Plugins use <strong>$wp_query->max_num_pages</strong>.<br
/> <span
id="more-1263"></span><br
/> <code>max_num_pages</code> is the result of available posts divided by the set number of posts per page. For example we set 10 posts per page, but we have on our starting page 14 posts, it will mess up the pagination.</p><p>My solution works with the WordPress pagination and looks like this:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//detect the set number of posts per page</span>
<span style="color: #000088;">$ppp</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'posts_per_page'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// first page 14 posts</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>is_paged<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$posts</span> <span style="color: #339933;">=</span> get_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'numberposts=14'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// second page with offset</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$paged</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$posts</span> <span style="color: #339933;">=</span> get_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'offset=14'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// all other pages with settings from backend</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$offset</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ppp</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$paged</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">14</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$posts</span> <span style="color: #339933;">=</span> get_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'offset='</span><span style="color: #339933;">.</span><span style="color: #000088;">$offset</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$posts</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$posts</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
        <span style="color: #666666; font-style: italic;">//your code </span>
    <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span></pre></div></div><p>This might be not the most intelligent solution, but it works. If anybody has a better idea, please let us know in the comments.<br
/><hr
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/hide-the-comment-pagination/" rel="bookmark" title="Permanent Link: Hide The Comment Pagination" class="liinternal">Hide The Comment Pagination</a></li><li><a
href="http://wpengineer.com/comment-pagination-and-reply-depth-in-wordpress-27/" rel="bookmark" title="Permanent Link: Comment Pagination And Reply Depth In WordPress 2.7" class="liinternal">Comment Pagination And Reply Depth In WordPress 2.7</a></li><li><a
href="http://wpengineer.com/quick-tipps-for-wordpress-query/" rel="bookmark" title="Permanent Link: Quick Tipps For WordPress Query" class="liinternal">Quick Tipps For WordPress Query</a></li><li><a
href="http://wpengineer.com/spelling-wordpress-always-correctly/" rel="bookmark" title="Permanent Link: Spelling WordPress Always Correctly" class="liinternal">Spelling WordPress Always Correctly</a></li><li><a
href="http://wpengineer.com/related-posts-on-category/" rel="bookmark" title="Permanent Link: Related Posts on Category" class="liinternal">Related Posts on Category</a></li></ul><hr
/><p><img
style="float:left;" src="http://wpengineer.com/favicon.ico" alt="WP Engineer Favicon"/> Thanks for subscribing our feed! <a
href="http://buysellads.com/buy/detail/3646/" class="liexternal">Sponsor the WP Engineer Blog</a> and get your brand in front of several hundred users per day!<br
/> &copy; <a
href="http://wpengineer.com/" class="liinternal">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p> ]]></content:encoded> <wfw:commentRss>http://wpengineer.com/correct-pagination-with-get_posts/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Database Caching 27/42 queries in 0.258 seconds using disk
Object Caching 725/800 objects using disk

Served from: wpengineer.com @ 2010-07-29 13:43:26 -->