<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
		>
	<channel>
		<title>Wordpress and Webdesign Forum go41 &#187; Tag: pagination - Recent Posts</title>
		<link>http://forum.go41.de/tags/pagination</link>
		<description>How To, tips, php and css code for your WordPress site</description>
		<language>en-US</language>
		<pubDate>Thu, 09 Feb 2012 19:28:58 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.1</generator>
				<atom:link href="http://forum.go41.de/rss/tags/pagination" rel="self" type="application/rss+xml" />

		<item>
			<title>Joern on "custom query loop with SELECT and pagination"</title>
			<link>http://forum.go41.de/topic/custom-query-loop-with-select-and-pagination#post-588</link>
			<pubDate>Wed, 28 Jul 2010 17:02:22 +0000</pubDate>
			<dc:creator>Joern</dc:creator>
			<guid isPermaLink="false">588@http://forum.go41.de/</guid>
			<description><![CDATA[<p>I do not know..</p>
<p>you might have to put previous_posts_link() and next_posts_link() into the plugin itself.</p>
<p>If you run other queries on that file WordPress might not 'know' which is the query you want to paginate and the variable for the current page is gone.</p>
<p>So this xxx_posts_link() has to follow the query you actually want to put into pages directly.</p>
<p>As you find on top of my query I display the page number if it's paged:<br />
<pre><code>&#60;?php if ($paged != 1  &#38;&#38; $paged) { echo(&#34; Seite $paged&#34; ); } ?&#62;</code></pre>
<p>I would echo the page number for testing only, in your plugin or where ever you call the plugin, to see if paging is set somehow.<br />
Like this:<br />
<pre><code>&#60;?php echo(&#34; this is page $paged&#34; ); ?&#62;</code></pre>
<p>I am learning more by trial and error than actually knowing how it works ..
</p>]]></description>
					</item>
		<item>
			<title>hunsford on "custom query loop with SELECT and pagination"</title>
			<link>http://forum.go41.de/topic/custom-query-loop-with-select-and-pagination#post-587</link>
			<pubDate>Wed, 28 Jul 2010 16:29:20 +0000</pubDate>
			<dc:creator>hunsford</dc:creator>
			<guid isPermaLink="false">587@http://forum.go41.de/</guid>
			<description><![CDATA[<p>Do you know if this will work in non-template files? I'm using the above custom query loop in a plugin file, but previous_posts_link() and next_posts_link() don't return anything.
</p>]]></description>
					</item>
		<item>
			<title>Joern on "custom query loop with SELECT and pagination"</title>
			<link>http://forum.go41.de/topic/custom-query-loop-with-select-and-pagination#post-187</link>
			<pubDate>Wed, 17 Mar 2010 15:32:29 +0000</pubDate>
			<dc:creator>Joern</dc:creator>
			<guid isPermaLink="false">187@http://forum.go41.de/</guid>
			<description><![CDATA[<p>I have a custom template listing only posts of one category (category-XX.php)<br />
Here I am listing only events, future events and passed events. Using the plugin 'MR Event' I get the date of all events easily into a custom field.</p>
<p>This list got quite long now and I was looking for a code to paginate the custom loop. Paging in a $pageposts = $wpdb-&#62;get_results($wp_query-&#62;request, OBJECT); loop is not so easy, but I found a solution here: wordpress.org/support/topic/232627</p>
<p>As this stuff is for advanced users only, I will give you the complete content of my category-XXX.php here.</p>
<p>To be seen here: <a href="http://www.linedancestompers.de/category/events/" rel="nofollow">http://www.linedancestompers.de/category/events/</a></p>
<pre><code>&#60;?php get_header(); ?&#62;
&#60;!-- cat &#39;your cat ID&#39; template name category-ID.php --&#62;
&#60;div id=&#34;content&#34;&#62;
&#60;?php if(!is_paged()) { ?&#62;
&#60;?php	if ( function_exists(&#39;mr_event_list_qf&#39;) ) { ?&#62;
&#60;h2&#62;Kommende Termine:&#60;/h2&#62;
&#60;?php mr_event_list_qf(&#39;date_format=d.m.Y&#39;,&#39;%DATE%: &#60;a href=&#34;%URL%&#34; title=&#34;%TITLE%&#34; &#62;%TITLE%&#60;/a&#62;&#39;) ?&#62;
&#60;?php } ?&#62;
&#60;?php } ?&#62;
&#60;h2&#62;Alle Termine&#60;?php if ($paged != 1  &#38;&#38; $paged) { echo(&#34; Seite $paged&#34; ); } ?&#62;:&#60;/h2&#62;

&#60;?php
$total = &#34;
    SELECT $wpdb-&#62;posts.*
    FROM $wpdb-&#62;posts
    LEFT JOIN $wpdb-&#62;postmeta ON ($wpdb-&#62;posts.ID = $wpdb-&#62;postmeta.post_id)
    WHERE $wpdb-&#62;postmeta.meta_key = &#39;mr_event&#39;
    AND $wpdb-&#62;posts.post_status = &#39;publish&#39;
    AND $wpdb-&#62;posts.post_type = &#39;post&#39;
    ORDER BY $wpdb-&#62;postmeta.meta_value DESC
    &#34;;
$totalposts = $wpdb-&#62;get_results($total, OBJECT); //see wordpress.org/support/topic/232627
$ppp = intval(&#39;12&#39;); //12 posts per page you might use $ppp = intval(get_query_var(&#39;posts_per_page&#39;));
$wp_query-&#62;found_posts = count($totalposts);
$wp_query-&#62;max_num_pages = ceil($wp_query-&#62;found_posts / $ppp);
$on_page = intval(get_query_var(&#39;paged&#39;));
if($on_page == 0){ $on_page = 1; }
$offset = ($on_page-1) * $ppp;
$wp_query-&#62;request = &#34;
    SELECT $wpdb-&#62;posts.*
    FROM $wpdb-&#62;posts
    LEFT JOIN $wpdb-&#62;postmeta ON ($wpdb-&#62;posts.ID = $wpdb-&#62;postmeta.post_id)
    WHERE $wpdb-&#62;postmeta.meta_key = &#39;mr_event&#39;
    AND $wpdb-&#62;posts.post_status = &#39;publish&#39;
    AND $wpdb-&#62;posts.post_type = &#39;post&#39;
    ORDER BY $wpdb-&#62;postmeta.meta_value DESC
    LIMIT $ppp OFFSET $offset&#34;;
$pageposts = $wpdb-&#62;get_results($wp_query-&#62;request, OBJECT);
 ?&#62;
 &#60;?php if ($pageposts): ?&#62;
  &#60;?php foreach ($pageposts as $post): ?&#62;
    &#60;?php setup_postdata($post); ?&#62;
&#60;div class=&#34;event&#34;&#62;
&#60;ul&#62;&#60;li&#62;&#60;?php if($mr_event_meta = get_post_meta($post-&#62;ID, &#39;mr_event&#39;, true)) { echo date(&#39;j.m.Y&#39;, $mr_event_meta);echo &#39; &#39;;echo date(&#39;G:i&#39;, $mr_event_meta);echo &#39; Uhr&#60;br /&#62;&#39;;  } ?&#62;&#60;/li&#62;&#60;/ul&#62;
	&#60;a href=&#34;&#60;?php the_permalink() ?&#62;&#34; rel=&#34;bookmark&#34; title=&#34;&#60;?php the_title(); ?&#62;&#34;&#62;&#60;?php the_title(); ?&#62;&#60;/a&#62;
&#60;div class=&#34;contenttext&#34;&#62;
&#60;?php the_content() ?&#62;
&#60;/div&#62;
&#60;/div&#62;
 &#60;?php endforeach; ?&#62;

&#60;?php else : ?&#62;
&#60;p&#62;No matching entries found.&#60;/p&#62;
&#60;?php endif; ?&#62;

&#60;div class=&#34;navigation&#34;&#62;
&#60;p&#62;&#60;span class=&#34;navleft&#34;&#62;&#60;?php previous_posts_link(&#39;&#38;laquo; Vorherige Seite&#39;) ?&#62;&#60;/span&#62;
&#60;span class=&#34;navright&#34;&#62;&#60;?php next_posts_link(&#39;N&#38;auml;chste Seite &#38;raquo;&#39;) ?&#62;&#60;/span&#62;&#60;/p&#62;
&#60;/div&#62;

&#60;/div&#62;
&#60;?php get_sidebar(); ?&#62;
&#60;?php get_footer(); ?&#62;</code></pre>
<p>having questions? Join us and ask!
</p>]]></description>
					</item>
		<item>
			<title>masteradmin on "bbpress front-page pagination Items per page"</title>
			<link>http://forum.go41.de/topic/bbpress-front-page-pagination-items-per-page#post-53</link>
			<pubDate>Wed, 14 Oct 2009 17:29:29 +0000</pubDate>
			<dc:creator>masteradmin</dc:creator>
			<guid isPermaLink="false">53@http://forum.go41.de/</guid>
			<description><![CDATA[<p><strong>get the title tag in header.php display the current page</strong></p>
<p>switching pages works well with the plugin explained above, but the title of the forum will always just show the forums name.</p>
<p>On page two however we have another URL and different topics, so the title should reflect this.</p>
<p>In a similar way as in WordPress you can easily add 'page X' to the title if it is paged and if you are on front-page.</p>
<p>In header.php you find:<br />
<pre><code>&#60;title&#62;&#60;?php bb_title() ?&#62;&#60;/title&#62;</code></pre>
<p>by adding 'if (is_front() &#38;&#38; $page&#62;1)' you can echo the page number if it is paged. It should look like this:<br />
<pre><code>&#60;title&#62;&#60;?php bb_title() ?&#62;&#60;?php if (is_front() &#38;&#38; $page&#62;1) {echo(&#34; page $page&#34; ); } ?&#62;&#60;/title&#62;</code></pre>
<p>Now, if you switch to page 2 it will display 'your forums name page 2'
</p>]]></description>
					</item>
		<item>
			<title>masteradmin on "bbpress front-page pagination Items per page"</title>
			<link>http://forum.go41.de/topic/bbpress-front-page-pagination-items-per-page#post-52</link>
			<pubDate>Wed, 14 Oct 2009 10:47:13 +0000</pubDate>
			<dc:creator>masteradmin</dc:creator>
			<guid isPermaLink="false">52@http://forum.go41.de/</guid>
			<description><![CDATA[<p>It took a while to find out that bbPress 0.9.0.5 doesn't use pagination on the frontpage.<br />
Having more topics than what is set in admin under 'Items per page:' will make the older ones disappear.<br />
It took a while to find the plugin 'Topics Per Page' ( <a href="http://bbpress.org/plugins/topic/front-page-topics/" rel="nofollow">http://bbpress.org/plugins/topic/front-page-topics/</a> ) which gives you a pagination bar with page numbers.</p>
<p>Installation went easy, putting it in the my-plugins/ folder after setting the number of topics or posts I wanted on each page. Edit topics-per-page.php to do this.</p>
<p>Now in front-page.php you still have to place the call for the function front_page_pages(); AFTER &#60;?php endforeach; endif; // $topics ?&#62; &#60;/table&#62;</p>
<p>Sure putting this code in the file and not activating the plugin first will make your frontpage stop running after this call. It's better to check first 'if function_exists'</p>
<p>In my front-page.php it looks like this now:<br />
<pre><code>&#60;?php endforeach; endif; // $topics ?&#62;
&#60;/table&#62;
&#60;?php	if (function_exists(&#39;front_page_pages&#39;)) { ?&#62;
&#60;div class=&#34;nav&#34;&#62;&#60;?php front_page_pages(); ?&#62;&#60;/div&#62;
&#60;?php } // end front_page_pages ?&#62;</code></pre>
<p>Where the first two lines should be already in your file!</p>
<p>Finally in readme.txt it says 'if you use rewrite slugs you MUST add a rule to your .htaccess'</p>
<p>The suggested rule <code>RewriteRule ^page/([0-9]+)/?$ /forums/?page=$1 [L,QSA]</code> works well if your forum is installed in a folder called /forums/</p>
<p>I installed it in the root folder of a subdomain, so for this installation I used<br />
<pre><code>RewriteRule ^page/([0-9]+)/?$ /?page=$1 [L,QSA]</code></pre>
<p>Now I enjoy pagination on the frontpage of bbPress, thanks to the Contributors _ck_ and mdawaffe
</p>]]></description>
					</item>
		<item>
			<title>Joern on "latest post as headline, followed by featured and subsequent below"</title>
			<link>http://forum.go41.de/topic/latest-post-as-headline-followed-by-featured-and-subsequent-below#post-47</link>
			<pubDate>Wed, 26 Aug 2009 18:05:15 +0000</pubDate>
			<dc:creator>Joern</dc:creator>
			<guid isPermaLink="false">47@http://forum.go41.de/</guid>
			<description><![CDATA[<p>Modify the front page view of arthemia to show most recent (newest) post as 'headline', next four older posts as 'featured' and the subsequent posts continuing below.</p>
<p>Arthemia normally shows in the Headline section posts assigned to the category Headlines. Featured section shows posts from the category featured. All other posts follow below. So older posts of of the two sections above will disappear as soon there is a new entry.</p>
<p>I modified the index.php of arthemia free version to show your last post in Headline section, the next for older posts are shown in Featured section and even older posts follow below and on subsequent pages.</p>
<p>As with this mod you show 10 posts on the frontpage, you should set the Reading Settings in your Wordpress dashboard to "Blog pages show at most 10 posts"<br />
With this setting pagination is working as it should.</p>
<p>The only modifications in the following code are in lines:<br />
10-12, 23, 30, 76-82</p>
<p>index.php code for normal flow of posts regardless any category:</p>
<pre><code>&#60;?php get_header(); ?&#62;

	&#60;?php if(!is_paged()) { ?&#62;

	&#60;div id=&#34;top&#34; class=&#34;clearfloat&#34;&#62;

		&#60;div id=&#34;headline&#34;&#62;
		&#60;img src=&#34;&#60;?php echo get_option(&#39;home&#39;); ?&#62;/wp-content/themes/arthemia/images/headline.png&#34; width=&#34;75px&#34; height=&#34;21px&#34; alt=&#34;&#34; /&#62;

		&#60;?php $lastposts = get_posts(&#39;numberposts=1&#39;);  //modified
 foreach($lastposts as $post) :  //modified
 setup_postdata($post); $do_not_duplicate = $post-&#62;ID;  //modified ?&#62;

	&#60;div class=&#34;title&#34;&#62;&#60;a href=&#34;&#60;?php the_permalink() ?&#62;&#34; rel=&#34;bookmark&#34;&#62;&#60;?php the_title(); ?&#62;&#60;/a&#62;&#60;/div&#62;
	&#60;div class=&#34;meta&#34;&#62;[&#60;?php the_time(&#39;j M Y&#39;) ?&#62; &#124; &#60;?php comments_popup_link(&#39;No Comment&#39;, &#39;One Comment&#39;, &#39;% Comments&#39;);?&#62; &#124; &#60;?php if(function_exists(&#39;the_views&#39;)) { the_views(); } ?&#62;]&#60;/div&#62;
	&#60;?php $values = get_post_custom_values(&#34;Headline&#34;);?&#62;
 	&#60;a href=&#34;&#60;?php the_permalink() ?&#62;&#34; rel=&#34;bookmark&#34; title=&#34;Permanent Link to &#60;?php the_title(); ?&#62;&#34;&#62;
&#60;img src=&#34;&#60;?php echo bloginfo(&#39;template_url&#39;); ?&#62;/scripts/timthumb.php?src=/&#60;?php
$values = get_post_custom_values(&#34;Image&#34;); echo $values[0]; ?&#62;&#38;w=300&#38;h=275&#38;zc=1&#38;q=100&#34;
alt=&#34;&#60;?php the_title(); ?&#62;&#34; class=&#34;left&#34; width=&#34;300px&#34; height=&#34;275px&#34;  /&#62;&#60;/a&#62;
	&#60;?php the_excerpt(); ?&#62;
	&#60;a href=&#34;&#60;?php the_permalink() ?&#62;&#34; rel=&#34;bookmark&#34; title=&#34;Permanent Link to &#60;?php the_title(); ?&#62;&#34;&#62;Read the full story &#38;raquo;&#60;/a&#62;
&#60;?php endforeach; //modified ?&#62;
	&#60;/div&#62;

	&#60;div id=&#34;featured&#34;&#62;

	&#60;img src=&#34;&#60;?php echo get_option(&#39;home&#39;); ?&#62;/wp-content/themes/arthemia/images/featured.png&#34; width=&#34;72px&#34; height=&#34;17px&#34; alt=&#34;&#34; /&#62;

&#60;?php query_posts(&#34;showposts=4&#38;offset=1&#34;); $i = 1;  //modified ?&#62;

      	&#60;?php while (have_posts()) : the_post(); ?&#62;
	&#60;div class=&#34;clearfloat&#34;&#62;
	&#60;?php $values = get_post_custom_values(&#34;Image&#34;);
	if (isset($values[0])) { ?&#62;
      &#60;a href=&#34;&#60;?php the_permalink() ?&#62;&#34; rel=&#34;bookmark&#34; title=&#34;Permanent Link to &#60;?php the_title(); ?&#62;&#34;&#62;
	&#60;img src=&#34;&#60;?php echo bloginfo(&#39;template_url&#39;); ?&#62;/scripts/timthumb.php?src=/&#60;?php
$values = get_post_custom_values(&#34;Image&#34;); echo $values[0]; ?&#62;&#38;w=100&#38;h=65&#38;zc=1&#38;q=100&#34;
alt=&#34;&#60;?php the_title(); ?&#62;&#34; class=&#34;left&#34; width=&#34;100px&#34; height=&#34;65px&#34;  /&#62;&#60;/a&#62;
      &#60;?php } ?&#62;
	&#60;div class=&#34;info&#34;&#62;&#60;a href=&#34;&#60;?php the_permalink() ?&#62;&#34; rel=&#34;bookmark&#34; class=&#34;title&#34;&#62;&#60;?php the_title(); ?&#62;&#60;/a&#62;
&#60;div class=&#34;meta&#34;&#62;[&#60;?php the_time(&#39;j M Y&#39;) ?&#62; &#124; &#60;?php comments_popup_link(&#39;No Comment&#39;, &#39;One Comment&#39;, &#39;% Comments&#39;);?&#62; &#124; &#60;?php if(function_exists(&#39;the_views&#39;)) { the_views(); } ?&#62;]&#60;/div&#62;	

&#60;/div&#62;
    	&#60;/div&#62;

      &#60;?php endwhile; ?&#62;

	&#60;/div&#62;

&#60;/div&#62;	

	&#60;div id=&#34;middle&#34; class=&#34;clearfloat&#34;&#62;
	&#60;img src=&#34;&#60;?php echo get_option(&#39;home&#39;); ?&#62;/wp-content/themes/arthemia/images/category.png&#34; class=&#34;clearfloat&#34; alt=&#34;&#34; /&#62;
	&#60;?php $display_categories = array(5,6,7,8,11); $i = 1;
	foreach ($display_categories as $category) { ?&#62;

	&#60;div id=&#34;cat-&#60;?php echo $i; ?&#62;&#34; class=&#34;category&#34;&#62;
		&#60;?php query_posts(&#34;showposts=1&#38;cat=$category&#34;)?&#62;
		&#60;span class=&#34;cat_title&#34;&#62;&#60;a href=&#34;&#60;?php echo get_category_link($category);?&#62;&#34;&#62;&#60;?php single_cat_title(); ?&#62;&#60;/a&#62;&#60;/span&#62;
		&#60;a href=&#34;&#60;?php echo get_category_link($category);?&#62;&#34;&#62;&#60;?php echo category_description($category); ?&#62;&#60;/a&#62;
	&#60;/div&#62;

	&#60;?php $i++; ?&#62;
    	&#60;?php } ?&#62;

	&#60;/div&#62;

	&#60;?php } ?&#62;

	&#60;div id=&#34;bottom&#34; class=&#34;clearfloat&#34;&#62;

	&#60;div id=&#34;front-list&#34;&#62;	

&#60;?php
  $page = (get_query_var(&#39;paged&#39;)) ? get_query_var(&#39;paged&#39;) : 1;  // checks the page you are on
  $num_of_posts = get_option(&#39;posts_per_page&#39;);  // gets settings of posts per page in admin - Reading Settings, first page shows 10 posts, so set to 10 in admin - Reading Settings
	if ( !is_paged()){
	query_posts(&#34;paged=$page&#38;offset=5&#38;posts_per_page=5&#34;); // if it is NOT paged show 5 posts with offset of 5 in headline and featured
 } else {
query_posts(&#34;paged=$page&#38;posts_per_page=$num_of_posts&#34;); } // if it is paged gets pagenumber and settings of posts per page in admin, 10 posts would be best  ?&#62;

	  &#60;?php while (have_posts()) : the_post(); ?&#62;		

	&#60;div class=&#34;clearfloat&#34;&#62;
	&#60;h3 class=cat_title&#62;&#60;?php the_category(&#39;, &#39;); ?&#62; &#38;raquo;&#60;/h3&#62;
	&#60;div class=&#34;title&#34;&#62;&#60;a href=&#34;&#60;?php the_permalink() ?&#62;&#34; rel=&#34;bookmark&#34;&#62;&#60;?php the_title(); ?&#62;&#60;/a&#62;&#60;/div&#62;
	&#60;div class=&#34;meta&#34;&#62;[&#60;?php the_time(&#39;j M Y&#39;) ?&#62; &#124; &#60;?php comments_popup_link(&#39;No Comment&#39;, &#39;One Comment&#39;, &#39;% Comments&#39;);?&#62; &#124; &#60;?php if(function_exists(&#39;the_views&#39;)) { the_views(); } ?&#62;]&#60;/div&#62;	

	&#60;div class=&#34;spoiler&#34;&#62;
	&#60;?php	$values = get_post_custom_values(&#34;Image&#34;);
	if (isset($values[0])) { ?&#62;
      &#60;a href=&#34;&#60;?php the_permalink() ?&#62;&#34; rel=&#34;bookmark&#34; title=&#34;Permanent Link to &#60;?php the_title(); ?&#62;&#34;&#62;
	&#60;img src=&#34;&#60;?php echo bloginfo(&#39;template_url&#39;); ?&#62;/scripts/timthumb.php?src=/&#60;?php
$values = get_post_custom_values(&#34;Image&#34;); echo $values[0]; ?&#62;&#38;w=150&#38;h=150&#38;zc=1&#38;q=100&#34;
alt=&#34;&#60;?php the_title(); ?&#62;&#34; class=&#34;left&#34; width=&#34;150px&#34; height=&#34;150px&#34;  /&#62;&#60;/a&#62;
      &#60;?php } ?&#62;

	&#60;?php the_excerpt(); ?&#62;
	&#60;/div&#62;

	&#60;/div&#62;

      &#60;?php endwhile; ?&#62;

	&#60;div class=&#34;navigation&#34;&#62;
		&#60;?php if(function_exists(&#39;wp_pagenavi&#39;)) { wp_pagenavi(); }
			else { ?&#62;

			&#60;div class=&#34;right&#34;&#62;&#60;?php next_posts_link(&#39;Next Page &#38;raquo;&#39;) ?&#62;&#60;/div&#62;
			&#60;div class=&#34;left&#34;&#62;&#60;?php previous_posts_link(&#39;&#38;laquo; Previous Page&#39;) ?&#62;&#60;/div&#62;
			&#60;?php } ?&#62;

	&#60;/div&#62;

	&#60;/div&#62;

	&#60;?php get_sidebar(); ?&#62;

	&#60;/div&#62;	

&#60;?php get_footer(); ?&#62;</code></pre>]]></description>
					</item>

	</channel>
</rss>

