<?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>thinkMoult &#187; theme</title>
	<atom:link href="http://thinkmoult.com/tag/theme/feed/" rel="self" type="application/rss+xml" />
	<link>http://thinkmoult.com</link>
	<description>Seriously who ever reads this description.</description>
	<lastBuildDate>Sun, 22 Jan 2012 04:58:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>thinkMoult blog design updated.</title>
		<link>http://thinkmoult.com/2010/04/30/thinkmoult-blog-design-updated/</link>
		<comments>http://thinkmoult.com/2010/04/30/thinkmoult-blog-design-updated/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 08:28:42 +0000</pubDate>
		<dc:creator>Dion Moult</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[redesign]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[thinkmoult]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://thinkmoult.com/2010/04/30/thinkmoult-blog-design-updated/</guid>
		<description><![CDATA[It&#8217;s come a long way since the original concept redesign back in the July of 2009. The thinkMoult blog has been incrementally updated probably once a month with small tweaks to the layout. The blog has been stripped originally from its (relatively) featureful edition to the bare essentials &#8211; ie. a streaming wall of text [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s come a long way since the <a href="http://thinkmoult.com/2009/07/21/blog-redesign/">original concept redesign</a> back in the July of 2009. The thinkMoult blog has been incrementally updated probably once a month with small tweaks to the layout. The blog has been stripped originally from its (relatively) featureful edition to the bare essentials &#8211; ie. a streaming wall of text with emphasis on clear headers and content areas.</p>
<p>To me a blog is a very much a written journal. Social and pictorial blogs aren&#8217;t &quot;blogs&quot; in my definition of the word.  As a result I&#8217;ve decided to condense things a little, cutting out pictures which don&#8217;t complement the article, focusing on clear typographical elements (pushing the limits of the beloved Arial font!) and effective use of padding rather than borders. I&#8217;m maintaining the simplicity of the previous layout (no sidebar, no link lists or fancy plugins) and sticking to my roots.</p>
<p>The design itself was inspired by the <a href="http://powazek.com/depo-skinny">Depo Skinny Theme</a> but with obvious edits here and there on font styles. What this implies is that I&#8217;ve also involuntarily drastically improved the semantics behind the blog itself &#8211; which is a good thing of course.</p>
<p>Everything should&#8217;ve been ported over such as avatar support in comments, asides along with my <a href="http://thinkmoult.com/2009/09/24/make-a-category-not-considered-as-a-post-in-wordpress/">asides category pagination hack</a>, and the various footer tweaks. There have also been a few edits here and there which add to the overall polish of the design.</p>
<p>Well, I hope you like it, and let me know if there is anything which looks messed up.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://thinkmoult.com/2010/04/30/thinkmoult-blog-design-updated/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Make a category not considered as a post in WordPress</title>
		<link>http://thinkmoult.com/2009/09/24/make-a-category-not-considered-as-a-post-in-wordpress/</link>
		<comments>http://thinkmoult.com/2009/09/24/make-a-category-not-considered-as-a-post-in-wordpress/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 14:25:18 +0000</pubDate>
		<dc:creator>Dion Moult</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Asides]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[category]]></category>
		<category><![CDATA[modification]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://thinkmoult.com/?p=1022</guid>
		<description><![CDATA[In other words, how do you make posts that are in a certain category not count towards total page post count in WordPress? A while back I set up Asides on this blog. The problem was that previously I was displaying 5 posts per page. Now with asides it still displayed 5 posts per page, [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>In other words, <strong>how do you make posts that are in a certain category not count towards total page post count in WordPress</strong>?</p>
<p><a href="http://thinkmoult.com/2009/09/20/implemented-a-new-asides-feature/">A while back I set up Asides</a> on this blog. The problem was that previously I was displaying 5 posts per page. Now with asides it still displayed 5 posts per page, but as asides are probably one sentence long at most I personally don&#8217;t consider them to be blog posts. This meant that it didn&#8217;t display 5 &#8220;real&#8221; posts per page. So, how do I fix this?</p>
<p><em>Disclaimer: I&#8217;m not experienced in the under-the-hood of WordPress and as a result some of this solution might be hackery. However it works for me, and that&#8217;s what counts.</em></p>
<h3>Problem 1: displaying 5 real posts per page regardless of how many asides there are.<em><br />
</em></h3>
<p>WordPress loops through a series of posts per page and displays them one by one. Initially I thought they would increment a counter, of which I could easily change so that if the post category was in &#8220;asides&#8221;, it will not increment the counter. However there were a couple flaws: 1) There was no counter, or I completely missed one, 2) The database queries sets the LIMITs from the administrator settings right at the very beginning, and 3) pagination will be completely messed up.</p>
<p>The solution was pretty simple, <strong>firstly we set the database query LIMIT to an obscenely large amount &#8211; more posts than we ever think we&#8217;ll need on a page</strong>. This can be done in the administrator panel. Change &#8220;display posts per page&#8221; to a random large value. I chose 15 because it seems pretty realistic that real posts + aside posts &lt; 15 for 99.9% of the time.</p>
<p><strong>The second step is to manually change the criteria for when the loop terminates</strong>. This way it will not actually show 15 posts, but instead <em>up to 15 posts</em>. What we&#8217;ll do is create a new counter, where ever time we display a post that isn&#8217;t an &#8220;aside&#8221;, we increment the counter, until it hits 5 posts (if I wanted 5 real posts per page) &#8211; at which time it&#8217;ll terminate the loop.</p>
<p>This can be done in the<em> wp-includes/query.php</em> page. To begin with we&#8217;ll need a new variable in the class for our counter. So below <code>class WP_Query {</code> we should add:</p>
<p><code>var $counting_up = 0;</code></p>
<p>Just to make sure that <code>$counting_up</code> resets itself as it should, we&#8217;ll add this to the <code>init()</code> function:</p>
<p><code>$this-&gt;counting_up = 0;</code></p>
<p>Now the next step is to modify the <code>the_post()</code> function. When the loop has started and the category is not an aside, we&#8217;ll increment our counter. In this example my aside category ID is category 429. This will be different for you, so you change it. So simply add this to the <code>the_post()</code> function:</p>
<p><code>if ( !in_category(429) &amp;&amp; $this-&gt;current_post != -1 ) {<br />
$this-&gt;counting_up++;<br />
}</code></p>
<p>Now we&#8217;ve got our counter, we&#8217;ll set up the loop to terminate correctly. This can be done in the <code>have_posts()</code> function. Notice this is the <code>have_posts()</code> function inside the WP_Query class, not outside. We can modify our if statement to terminate when our counter hits 4 posts (as the first isn&#8217;t counted &#8211; therefore in effect we&#8217;ll display 5 real posts), and also when we don&#8217;t have a <code>do_not_terminate</code> variable set to the WP_Query. Why this <code>do_not_terminate</code> variable is important is if we ever need to override this, as well as later I&#8217;ll explain when we look at pagination issues. Here is my completed modified if statement:</p>
<p><code>if ($this-&gt;counting_up == 4 &amp;&amp; !$this-&gt;query_vars['do_not_terminate']) {<br />
$this-&gt;in_the_loop = false;<br />
do_action_ref_array('loop_end', array(&amp;$this));<br />
$this-&gt;rewind_posts();<br />
return false;<br />
} elseif ($this-&gt;current_post + 1 &lt; $this-&gt;post_count) {<br />
return true;<br />
} elseif ($this-&gt;current_post + 1 == $this-&gt;post_count &amp;&amp; $this-&gt;post_count &gt; 0) {<br />
do_action_ref_array('loop_end', array(&amp;$this));<br />
$this-&gt;rewind_posts();<br />
}</code></p>
<p>Now we&#8217;ve solved problem 1, and 5 real posts are displaying on our front page, let&#8217;s move on to problem 2.</p>
<h3>Problem 2: previous page, or going to older posts will no longer work.</h3>
<p>Since pages are pretty obsolete at this point, <strong>we&#8217;ll switch to using offsets</strong>. This is because each page will no longer display a fixed number of posts, <strong>each may display a variable amount of posts, minimum being 5 (that we set just now), and maximum being 15 (that we set at the very beginning)</strong>. So to start we&#8217;ll hop over to our <code>index.php</code> in our theme file, and simply get the offset from the URL and pass it through to our post loop. Here goes:</p>
<p><code>&lt;?php if ($_GET['offset'] &amp;&amp; is_numeric($_GET['offset'])) {<br />
query_posts('offset='. $_GET['offset']); $offsetting = $_GET['offset'];<br />
} else { $offsetting = 0; } ?&gt;</code></p>
<p>So with that code in <code>index.php</code>, we can now visit <em>myblogsite.com/?offset=20</em> and offset our posts by 20. To determine how many posts to offset by in previous pages, we simply take how much we&#8217;re currently offset by, and add all the posts we&#8217;ve displayed on the page, regardless of whether or not it is an aside or a real post. To do this we need another counter. So we&#8217;ll initialise our counter, perhaps near the beginning of <code>index.php</code>:</p>
<p><code>&lt;?php $on_page = 0; ?&gt;</code></p>
<p>&#8230; then within our <code>while (have_posts()) {</code> loop, (or whatever equivalent loop your theme uses), we&#8217;ll just increment it:</p>
<p><code>&lt;?php $on_page++; ?&gt;</code></p>
<p>So then we recode our &#8220;previous posts&#8221; link to go to:</p>
<p><code>&lt;a href="http://yourblog.com/?offset=&lt;?php echo $offsetting + $on_page; ?&gt;" &gt;Previous posts&lt;/a&gt;</code></p>
<p>That was simple, eh? This brings us to problem 3.</p>
<h3>Problem 3: newer posts don&#8217;t work, for obvious reasons.</h3>
<p>Going forward in time is a little bit more complex. We want to calculate how much <em>less</em> we should offset by. To do this we&#8217;ll create a function to calculate this. The function will need to know how much we&#8217;re currently offset by. Based on that, <strong>it&#8217;ll query 15 posts into the future, then loop through those posts in reverse order</strong>. If it can&#8217;t go 15 posts into the future (eg: on the first page, and perhaps the second), it&#8217;ll go as far into the future as it can. <strong>When looping through, it&#8217;ll record the category of each of the posts</strong>. Whenever it hits a post, it&#8217;ll increment the count we want to offset less by. When we hit a post that category isn&#8217;t an aside (category 429 in my example), it&#8217;ll increment a counter that determines how many real posts we&#8217;ve hit so far. So therefore we have two counters. When the real counter hits 6 posts, it&#8217;ll terminate the offset counter. This is because I want 5 real posts per page, and based on how we coded problem 1, we know that the last post of any page must be a real post, not an aside.</p>
<p>We can place this function in the functions.php file of our theme. Here is the function, of which lazy people can copy and paste:</p>
<p><code>function back_to_the_future($offset = 0) {<br />
$new_offset = $offset-15;<br />
if ($new_offset &lt; 0) {<br />
$new_offset = 0;<br />
}<br />
$diff_offset = $offset - $new_offset;<br />
$future_query = new WP_Query(array(<br />
'showposts' =&gt; $diff_offset,<br />
'order' =&gt; 'DESC',<br />
'offset' =&gt; $new_offset,<br />
'do_not_terminate' =&gt; TRUE<br />
));</code></p>
<p><code>$post_data = array();</code></p>
<p><code>while ($future_query-&gt;have_posts()) {<br />
if ($diff_offset == 0) {<br />
break;<br />
} else {<br />
$diff_offset--;<br />
}<br />
$future_query-&gt;the_post();<br />
$cat_id = get_the_category();<br />
$cat_id = $cat_id[0]-&gt;cat_ID;<br />
$post_data[] = $cat_id;<br />
}</p>
<p>$post_data = array_reverse($post_data);<br />
$count_posts = 0;<br />
$count_total = 0;</p>
<p>foreach ($post_data as $post_cat) {<br />
if ($post_cat != 429) {<br />
$count_posts++;<br />
}<br />
if ($count_posts == 6) {<br />
break;<br />
} else {<br />
$count_total++;<br />
}<br />
}</p>
<p></code></p>
<p><code> return $offset - $count_total;<br />
}</code></p>
<p>People who looked through the code will realise that we passed the <code>do_not_terminate</code> variable to WP_Query that we set up when addressing Problem 1. This is required because if we didn&#8217;t, we won&#8217;t get 15 posts into the future, instead we&#8217;ll just get however many posts starting from 15 posts into the future that include 5 real posts &#8211; which is totally useless.</p>
<p>To finish off nicely we&#8217;ll edit our &#8220;newer posts&#8221; link to use this calculated offset in our <code>index.php</code> file, but only display when we have a proper offset to show and we&#8217;re not on the first page.</p>
<p><code>&lt;?php if ($future_offset != 0 || !empty($offsetting)) { ?&gt;<br />
&lt;a href="http://yourblog.com/?offset=&lt;?php echo $future_offset; ?&gt;"&gt;Newer Posts&lt;/a&gt;<br />
&lt;?php } ?&gt;</code></p>
<p>Tada &#8211; all done! I hope that helped somebody out there, but if not at least I have it for archival purposes. If you&#8217;re using it, let me know how it goes!</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://thinkmoult.com/2009/09/24/make-a-category-not-considered-as-a-post-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

