<?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>iamnotagoodartist &#187; How To</title>
	<atom:link href="http://iamnotagoodartist.com/category/how-to/feed/" rel="self" type="application/rss+xml" />
	<link>http://iamnotagoodartist.com</link>
	<description>a blog of creativity</description>
	<lastBuildDate>Thu, 10 May 2012 03:04:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>AdBlock Detection with JavaScript / jQuery Update</title>
		<link>http://iamnotagoodartist.com/how-to/adblock-detection-with-javascript-jquery-update/</link>
		<comments>http://iamnotagoodartist.com/how-to/adblock-detection-with-javascript-jquery-update/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 02:58:26 +0000</pubDate>
		<dc:creator>tommy</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://iamnotagoodartist.com/?p=1454</guid>
		<description><![CDATA[(Yo! This is an update to my Show a Message to AdBlock Users with jQuery / JavaScript post, which I don&#8217;t think works anymore!) HTML &#60;div class=&#34;adsense&#34;&#62; &#60;!-- AdSense code goes here! --&#62; &#60;/div&#62; jQuery $(document).ready(function(){ setTimeout(&#34;checkAds();&#34;, 1000); }); function &#8230; <a href="http://iamnotagoodartist.com/how-to/adblock-detection-with-javascript-jquery-update/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>(<strong>Yo!</strong> This is an update to my <a href="http://iamnotagoodartist.com/how-to/show-a-message-to-adblock-users-with-jquery-javascript/">Show a Message to AdBlock Users with jQuery / JavaScript</a> post, which I don&#8217;t think works anymore!)</p>
<p><span id="more-1454"></span></p>
<h2>HTML</h2>
<pre class="brush: html">&lt;div class=&quot;adsense&quot;&gt;
	&lt;!-- AdSense code goes here! --&gt;
&lt;/div&gt;</pre>
<h2>jQuery</h2>
<pre class="brush: js">$(document).ready(function(){
        setTimeout(&quot;checkAds();&quot;, 1000);
});

function checkAds() {
        if ($(&quot;.adsense&quot;).height() == &quot;0&quot;) {
                $(&quot;.adsense&quot;).after(&quot;&lt;div class=&#039;alt&#039;&gt;&lt;h3&gt;Don&#039;t like ads?&lt;/h3&gt;&lt;p&gt;Me neither.&lt;/p&gt;&lt;p&gt;But you should know that the ads on this site help pay for hosting, domain renewal, and keeping me motivated to make other oddball apps and websites.&lt;/p&gt;&lt;p&gt;Please consider disabling your adblock software for this domain. In return, I&#039;ll give you an appreciative high-five if we ever meet in real life.&lt;/p&gt;&lt;p&gt;-Tommy&lt;/p&gt;&lt;/div&gt;&quot;);
        }
}</pre>
<h2>How It Works / Demo</h2>
<p>Pretty straightforward, really. This waits a second after the doc loads and sees if the <code>.adsense</code> block has any height. If not, it puts a message after it.</p>
<p>The old code used math and tried to count the number of children, but it was sort of clunky even when it did work.</p>
<p>Like before, don&#8217;t expect this method to be fullproof. I&#8217;m open to other ways.</p>
<p>To see it in action, visit my <a href="http://bigimg.it/">BigImg.it</a> app with and without AdBlock enabled.</p>
]]></content:encoded>
			<wfw:commentRss>http://iamnotagoodartist.com/how-to/adblock-detection-with-javascript-jquery-update/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dead Simple PHP Maintenance Lock Out</title>
		<link>http://iamnotagoodartist.com/how-to/dead-simple-php-maintenance-lock-out/</link>
		<comments>http://iamnotagoodartist.com/how-to/dead-simple-php-maintenance-lock-out/#comments</comments>
		<pubDate>Sun, 14 Nov 2010 17:20:08 +0000</pubDate>
		<dc:creator>tommy</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[lock out]]></category>
		<category><![CDATA[maintenance]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://iamnotagoodartist.com/?p=1443</guid>
		<description><![CDATA[Here&#8217;s a quick and dirty way to lock people out of viewing your PHP site while you&#8217;re working on it. Put this in a base file or at the top of any page that you don&#8217;t want rendered. &#60;?php if &#8230; <a href="http://iamnotagoodartist.com/how-to/dead-simple-php-maintenance-lock-out/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick and dirty way to lock people out of viewing your PHP site while you&#8217;re working on it. Put this in a base file or at the top of any page that you don&#8217;t want rendered.</p>
<pre class="brush: php">&lt;?php if (!isset($_GET[&quot;maint&quot;])) { exit(&quot;Working... come back later!&quot;); } ?&gt;</pre>
<p>You can view it by appending <code>?maint</code> to all the URLs, which normal visitors won&#8217;t know. Of course, you can use other attribute names or text.</p>
<p>Is this the most secure way to do it? Definitely not. But for most purposes, it&#8217;s totally fine.</p>
]]></content:encoded>
			<wfw:commentRss>http://iamnotagoodartist.com/how-to/dead-simple-php-maintenance-lock-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Semi-Transparent Mockup Overlays with CSS / jQuery UI</title>
		<link>http://iamnotagoodartist.com/how-to/semi-transparent-mockup-overlays-with-css-jquery-ui/</link>
		<comments>http://iamnotagoodartist.com/how-to/semi-transparent-mockup-overlays-with-css-jquery-ui/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 18:49:27 +0000</pubDate>
		<dc:creator>tommy</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[espresso]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery ui]]></category>

		<guid isPermaLink="false">http://iamnotagoodartist.com/?p=1368</guid>
		<description><![CDATA[I recently needed to convert some PSDs to HTML/CSS with pretty high accuracy, that is, the finished webpages needed to look very close to their original mockups. As is customary nerd style, I wrote some code to help me do &#8230; <a href="http://iamnotagoodartist.com/how-to/semi-transparent-mockup-overlays-with-css-jquery-ui/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently needed to convert some PSDs to HTML/CSS with pretty high accuracy, that is, the finished webpages needed to look very close to their original mockups. As is customary nerd style, I wrote some code to help me do that.</p>
<p><span id="more-1368"></span></p>
<p>(These demos and pictures use <a href="http://iamnotagoodartist.com/web-design/movie-monster/">my Movie Monster gig</a>, because the aforementioned project isn&#8217;t ready to be talked about.)</p>
<h2>Keeping It Simple with CSS</h2>
<p><a href="http://iamnotagoodartist.com/wp-content/uploads/2010/07/mockupoverlay_css.html"><img src="http://iamnotagoodartist.com/wp-content/uploads/2010/07/mockupoverlay_css.jpg" alt="Semi-Transparent Mockup Overlays with CSS Demo" title="" width="535" height="358" class="aligncenter size-full wp-image-1371" /></a></p>
<p><a href="http://iamnotagoodartist.com/wp-content/uploads/2010/07/mockupoverlay_css.html">Demo!</a></p>
<pre class="brush: html">&lt;div id=&quot;mockupoverlay_original&quot;&gt;original&lt;/div&gt;

&lt;style type=&quot;text/css&quot;&gt;
#mockupoverlay_original {
	background-color: rgba(0,0,0,.5);
	font-size: 12px;
	color: white;
	position: absolute;
	top: 5px;
	right: 5px;
	height: auto;
	font-weight: bold;
	padding: 5px 10px;
	cursor: pointer;
	z-index: 1000 !important;
}
#mockupoverlay_original:active {
	background: url(&quot;mockupoverlay_original.jpg&quot;) top center no-repeat;
	padding: 0;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	text-indent: -5000px;
}
&lt;/style&gt;</pre>
<p>This affixes an &#8220;Original&#8221; button to the top right of the page that, when clicked, overlays the original mockup on top of everything, centered and at the top. Sweet and simple, it&#8217;s just a line of HTML and some CSS. Wowza!</p>
<p>Tip: If you realtime edit your CSS with <a href="http://chrispederick.com/work/web-developer/">Web Developer Extension</a> like I do, you can change that <code>:active</code> pseudo-class to <code>:hover</code> and add something like <code>opacity: .5;</code> to it. That&#8217;s called <a href="http://en.wikipedia.org/wiki/Onion_skinning">onion skinning</a>, an animation technique.</p>
<h2>Making It Hot with jQuery UI</h2>
<p><a href="http://iamnotagoodartist.com/wp-content/uploads/2010/07/mockupoverlay_jqui.html"><img src="http://iamnotagoodartist.com/wp-content/uploads/2010/07/mockupoverlay_jqui.jpg" alt="Semi-Transparent Mockup Overlays with CSS and jQuery UI Demo" title="" width="536" height="371" class="aligncenter size-full wp-image-1372" /></a></p>
<p><a href="http://iamnotagoodartist.com/wp-content/uploads/2010/07/mockupoverlay_jqui.html">Demo!</a></p>
<pre class="brush: html">&lt;div id=&quot;mockupoverlay_slider&quot;&gt;&lt;/div&gt;
&lt;div id=&quot;mockupoverlay_original&quot;&gt;&lt;/div&gt;

&lt;link href=&quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/base/jquery-ui.css&quot; type=&quot;text/css&quot; rel=&quot;stylesheet&quot; media=&quot;screen&quot; /&gt;
&lt;style type=&quot;text/css&quot;&gt;
#mockupoverlay_slider {
	z-index: 999;
	font-size: .75em;
	position: fixed;
	width: 50px;
	top: 15px;
	right: 15px;
	opacity: .33;
}
#mockupoverlay_slider:hover { opacity: .66; }
#mockupoverlay_original {
	z-index: 900;
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: url(&quot;mockupoverlay_original.jpg&quot;) top center no-repeat;
	opacity: 1;
	display: none;
}
&lt;/style&gt;
&lt;script src=&quot;http://www.google.com/jsapi&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;google.load(&quot;jquery&quot;, &quot;1&quot;);  google.load(&quot;jqueryui&quot;, &quot;1&quot;);&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(function() {
	$(&quot;#mockupoverlay_slider&quot;).slider({ step: 10, change: function(event, ui) {
		$(&quot;#mockupoverlay_original&quot;).css(&quot;height&quot;, $(document).height());
		mockup_opacity = $(&#039;#mockupoverlay_slider&#039;).slider(&#039;value&#039;)/100;
		if (mockup_opacity == 0) {
			$(&quot;#mockupoverlay_original&quot;).hide();
		} else {
			$(&quot;#mockupoverlay_original&quot;).show().css(&quot;opacity&quot;, mockup_opacity);
		}
	} });
});
&lt;/script&gt;</pre>
<p>Here, instead of an &#8220;Original&#8221; button, there&#8217;s a slider, courtesy of <a href="http://jqueryui.com/">jQuery UI</a>, that controls the opacity of the overlay. All the way to the left, it&#8217;s hidden and you can interact with the page normally. All the way to the right, it&#8217;s fully opaque. Anywhere in the middle, it&#8217;s some fractional semi-transparency. The overlay also stretches to the entire height of the document, not just the first 100%, so you can scroll vertically.</p>
<p>You&#8217;ll notice that everything that can be is pulled in from Google&#8217;s CDN: jQuery, jQuery UI, and the base jQuery UI theme. Because why not?</p>
<h2>Use It or Lose It</h2>
<p>To use either of these approaches, copy its code and place it at the bottom of your HTML just before the closing <code>&lt;/html&gt;</code> tag. Then either name your mockup image &#8220;mockupoverlay_original.jpg&#8221; and keep it in the same folder or modify the CSS to point to wherever/whatever it may be.</p>
<p>Make sense? Let me know if you find good use for it.</p>
]]></content:encoded>
			<wfw:commentRss>http://iamnotagoodartist.com/how-to/semi-transparent-mockup-overlays-with-css-jquery-ui/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Auto-Hiding &#8220;Back to Top&#8221; Link with jQuery</title>
		<link>http://iamnotagoodartist.com/how-to/auto-hiding-back-to-top-link-with-jquery/</link>
		<comments>http://iamnotagoodartist.com/how-to/auto-hiding-back-to-top-link-with-jquery/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 20:25:35 +0000</pubDate>
		<dc:creator>tommy</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://iamnotagoodartist.com/?p=1230</guid>
		<description><![CDATA[A common usability feature on a lot of sites is a &#8220;Back to top&#8221; link at the bottom of long pages, allowing users to quickly get back to the start of the document without scrolling. These are often built into &#8230; <a href="http://iamnotagoodartist.com/how-to/auto-hiding-back-to-top-link-with-jquery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A common usability feature on a lot of sites is a &#8220;Back to top&#8221; link at the bottom of long pages, allowing users to quickly get back to the start of the document without scrolling. <span id="more-1230"></span></p>
<p>These are often built into the CMS or template itself rather than the content, so it&#8217;s entirely possible for them to appear on pages too short to be useful.</p>
<p>Here&#8217;s a jQuery function I wrote to remove the &#8220;Back to top&#8221; link if the page&#8217;s content isn&#8217;t longer than the window.</p>
<pre class="brush: js">jQuery.fn.autohidebacktotop = function() {
	if ($(&quot;html, body&quot;).height() &lt;= $(window).height()) {
		$(&quot;#autohidebacktotop&quot;).remove();
	}
	this.bind(&quot;click&quot;, function() {
		$(&quot;html, body&quot;).animate({scrollTop:0});
		return false;
	});
}; </pre>
<p>The accompanying HTML:</p>
<pre class="brush: html">&lt;p id=&quot;autohidebacktotop&quot;&gt;&lt;a href=&quot;#&quot;&gt;Back to top&lt;/a&gt;&lt;/p&gt;</pre>
<p>And then you can call it like so:</p>
<pre class="brush: js">$(document).ready(function(){
	$(&quot;#autohidebacktotop&quot;).autohidebacktotop();
});</pre>
<h2>How is this better?</h2>
<ul>
<li>Gracefully degrading, still works if JavaScript isn&#8217;t enabled</li>
<li><code>#autohidebacktotop</code> can be styled with CSS as normal</li>
<li>Nifty scrolling animation</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://iamnotagoodartist.com/how-to/auto-hiding-back-to-top-link-with-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Show a Message to AdBlock Users with jQuery / JavaScript</title>
		<link>http://iamnotagoodartist.com/how-to/show-a-message-to-adblock-users-with-jquery-javascript/</link>
		<comments>http://iamnotagoodartist.com/how-to/show-a-message-to-adblock-users-with-jquery-javascript/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 00:41:26 +0000</pubDate>
		<dc:creator>tommy</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[espresso]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://iamnotagoodartist.com/?p=939</guid>
		<description><![CDATA[Hey! I&#8217;ve written another quick method to detect AdBlock that works better than this one, I think. I&#8217;m leaving this one for posterity. AdBlock is pretty much the best thing to ever happen to the internets. That being said, sometimes &#8230; <a href="http://iamnotagoodartist.com/how-to/show-a-message-to-adblock-users-with-jquery-javascript/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Hey!</strong> I&#8217;ve written another <a href="http://iamnotagoodartist.com/how-to/adblock-detection-with-javascript-jquery-update/">quick method to detect AdBlock</a> that works better than this one, I think. I&#8217;m leaving this one for posterity.</p>
<p><span id="more-939"></span></p>
<div id="attachment_943" class="wp-caption alignleft" style="width: 260px"><a href="http://iamnotagoodartist.com/wp-content/uploads/2009/10/adblock.gif"><img src="http://iamnotagoodartist.com/wp-content/uploads/2009/10/adblock.gif" alt="On.. Off... On.." title="adblock" width="250" height="230" class="size-full wp-image-943" /></a><p class="wp-caption-text">On.. Off... On..</p></div>
<p><a href="http://adblockplus.org/en/">AdBlock</a> is pretty much the best thing to ever happen to the internets. That being said, sometimes it&#8217;s important to make money. You know, like, when you&#8217;re a poor dude. With bills. And a stomach that wants food. And web hosting to pay for.</p>
<p>I threw together some jQuery the other day to display a little message to visitors with AdBlock running and blocking, in my case, Google AdSense ads. It doesn&#8217;t block them from content or do anything cruel, but it does lightly suggest they disable the software while here.</p>
<p><strong>Note: </strong>This hasn&#8217;t been tested with all browsers, platforms, and advertising systems. You may have to tweak it to get it work in your situation. It may also not be future-proof, as AdBlock undoubtedly changes its formula as the internet evolves.</p>
<h2>The HTML</h2>
<pre class="brush: html">
&lt;div class=&quot;adsense&quot;&gt;
	&lt;!-- AdSense code goes here! --&gt;
&lt;/div&gt;
&lt;div id=&quot;search&quot;&gt;
	&lt;!-- something else goes here maybe! --&gt;
&lt;/div&gt;
</pre>
<p>Wrap all your ads in a div with a class of &#8220;adsense&#8221;. This HTML only has one, but you can have as many ads as you need. The &#8220;search&#8221; div doesn&#8217;t necessarily have to be search, just was in my case. Simply pick an element with a unique ID or class to have your message appear by (or in place of).</p>
<h2>The jQuery</h2>
<pre class="brush: js">
$(document).ready(function(){
	if (($(&quot;.adsense *&quot;).size() == $(&quot;.adsense&quot;).size()*2) || ($(&quot;.adsense *&quot;).size() == 0)){
		$(&quot;#search&quot;).prepend(&quot;&lt;div class=&#039;adblock&#039;&gt;&lt;p&gt;&lt;strong&gt;Oh No!&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;This is where you make an emotional appeal to your visitors, urging them to turn off AdBlock when visiting your site. I&#039;ll leave that up to you.&lt;/p&gt;&lt;p&gt;Thanks!&lt;/p&gt;&lt;/div&gt;&quot;);
	};
});
</pre>
<p>AdBlock doesn&#8217;t remove those &#8220;adsense&#8221; divs, just their contents. This bit of JavaScript checks to see if the number of those div containers is equal to itself times two <em>or</em> if they&#8217;re all empty. (Curiously, if you check for one, AdBlock interprets that as a shifty workaround and removes the other. Don&#8217;t ask. Just copy.) If the logic returns true, an appreciative and humble message is prepended to the &#8220;search&#8221; div.</p>
<p>If you&#8217;d rather the message appear after the &#8220;search&#8221; div, use &#8220;<a href="http://docs.jquery.com/Manipulation/append">append</a>&#8221; instead of &#8220;prepend&#8221; in line 3. If you&#8217;d rather it replace the contents of the div instead of affixing it, use &#8220;<a href="http://docs.jquery.com/Attributes/html">html</a>&#8220;.</p>
<p>The div wrapper around our message is for CSS and serves no functional purpose. Modify to your liking, just make sure the whole shebang is treated as a variable, contained (and not broken) by quotes.</p>
<h2>The CSS</h2>
<pre class="brush: css">
.adblock {
	border: 1px solid #828282;
	padding: 10px;
	background-color: #ece5dc;
}
.adblock strong { font-size: 16px; }
</pre>
<p>Optional. Pretty self-explanatory.</p>
<h2>The Verdict</h2>
<p>To see it in action, disable and enable AdBlock and refresh any page on this site. Did it work?</p>
<div class="disclaimer">
<h2>11/22/10 Update</h2>
<p>In case you didn&#8217;t see at the top, I&#8217;m not so sure this method is any good anymore, so I wrote <a href="http://iamnotagoodartist.com/how-to/adblock-detection-with-javascript-jquery-update/">a new way</a> that ought to do the trick. Thanks for stopping by!</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://iamnotagoodartist.com/how-to/show-a-message-to-adblock-users-with-jquery-javascript/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>WordPress: Excluding Categories on Secondary Front Pages</title>
		<link>http://iamnotagoodartist.com/how-to/wordpress-excluding-categories-on-secondary-front-pages/</link>
		<comments>http://iamnotagoodartist.com/how-to/wordpress-excluding-categories-on-secondary-front-pages/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 13:52:59 +0000</pubDate>
		<dc:creator>tommy</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://iamnotagoodartist.com/?p=607</guid>
		<description><![CDATA[More precisely, this tutorial covers how to exclude categories on paged front pages, index.php, beyond the first default listing. Excluding certain categories from the front page is a pretty easy task, just use the query_posts() function to remove those categories &#8230; <a href="http://iamnotagoodartist.com/how-to/wordpress-excluding-categories-on-secondary-front-pages/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>More precisely, this tutorial covers how to exclude categories on paged front pages, index.php, beyond the first default listing.</p>
<p>Excluding certain categories from the front page is a pretty easy task, just use the <a href="http://codex.wordpress.org/Template_Tags/query_posts"><em>query_posts()</em></a> function to remove those categories before going into the <a href="http://codex.wordpress.org/The_Loop">loop</a>, like so:</p>
<pre class="brush: php">&lt;?php if ( is_home() ) {
    query_posts(&quot;cat=-3&quot;);
}
while (have_posts()) : the_post(); ?&gt;</pre>
<p>But if the visitor tries to see the next set of posts through &#8220;Older Entries,&#8221; the same results are queried. Instead, use this:</p>
<pre class="brush: php">&lt;?php if ( is_home() ) {
    query_posts(&quot;paged=$paged&amp;cat=-3&quot;);
}
while (have_posts()) : the_post(); ?&gt;</pre>
<p>We can tell <em>query_posts()</em> which set of posts to display with the <em>paged</em> parameter and the <em>$paged</em> variable, a WordPress variable which returns the current page number (1 for the first, 2 for the second, and so on).</p>
]]></content:encoded>
			<wfw:commentRss>http://iamnotagoodartist.com/how-to/wordpress-excluding-categories-on-secondary-front-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress: How to Sort Category Archive Posts by Subcategory</title>
		<link>http://iamnotagoodartist.com/how-to/wordpress-how-to-sort-category-archive-posts-by-subcategory/</link>
		<comments>http://iamnotagoodartist.com/how-to/wordpress-how-to-sort-category-archive-posts-by-subcategory/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 17:30:31 +0000</pubDate>
		<dc:creator>tommy</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[featu]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://iamnotagoodartist.com/?p=581</guid>
		<description><![CDATA[By default, WordPress sorts posts in reverse chronological order, with the most recent post being at the top and the least recent at the bottom. Normally, that&#8217;s totally cool, since that&#8217;s the way we&#8217;ve been accustomed to reading blogs, but &#8230; <a href="http://iamnotagoodartist.com/how-to/wordpress-how-to-sort-category-archive-posts-by-subcategory/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>By default, WordPress sorts posts in reverse chronological order, with the most recent post being at the top and the least recent at the bottom. Normally, that&#8217;s totally cool, since that&#8217;s the way we&#8217;ve been accustomed to reading blogs, but what about when you&#8217;d like a little more organization?</p>
<p>Let&#8217;s say, for example, we&#8217;ve got a Music category with music genres as subcategories and posts specific to those genres organized respectively:</p>
<ul>
<li>Music
<ul>
<li>Rock
<ul>
<li>&#8220;The History of AC/DC&#8221;</li>
</ul>
</li>
<li>Hip Hop
<ul>
<li>&#8220;What Ever Happened to Bell Biv Devoe?&#8221;</li>
</ul>
</li>
<li>Pop
<ul>
<li>etc</li>
</ul>
</li>
<li>Jazz</li>
<li>etc</li>
</ul>
</li>
</ul>
<p>When viewing the Music category archive, these subcategory posts will be displayed all mixed in together and in reverse chronological. What we&#8217;d rather have is each subcategory given its own individual listing of its posts, prefaced by an H2 title and subcategory/genre description. We&#8217;ll order the subcats alphabetically; their posts chronologically. </p>
<p><span id="more-581"></span>To do this, we&#8217;ll modify/create a <a href="http://codex.wordpress.org/Category_Templates">category template</a> for our Music category, in my case, <em>category-17.php</em>.</p>
<p>We&#8217;ll use the <a href="http://codex.wordpress.org/Function_Reference/get_categories">get_categories()</a> WordPress function to create an array of the current category&#8217;s subcategories.</p>
<pre class="brush: php">&lt;?php $categories = get_categories(&quot;child_of=17&quot;); </pre>
<p>The <em>child_of</em> parameter tells the function to grab all the child categories of 17, the ID for our Music category. You&#8217;ll substitute whatever ID your category is. The function will automatically order the subcats alphabetically, but you can also set it to order by ID.</p>
<p>Next, we&#8217;ll use PHP&#8217;s <a href="http://us3.php.net/foreach">foreach construct</a> to iterate through each array asset, find its subcat ID, and <a href="http://codex.wordpress.org/Template_Tags/query_posts">query_posts()</a> to grab that subcat&#8217;s posts.</p>
<pre class="brush: php">foreach ($categories as $cat) {
	query_posts(&quot;cat=$cat-&gt;cat_ID&amp;showposts=-1&amp;order=ASC&amp;orderby=name&quot;);</pre>
<p>The <em>showposts=-1</em> parameter tells <em>query_posts</em> to grab all the posts without stopping at the default number for your installation, and <em>order=ASC</em> orders them in normal chronological order (default is DESC, descending).</p>
<p>Then we use a simple <a href="http://codex.wordpress.org/The_Loop_in_Action">WordPress loop</a> to display that post&#8217;s goodies, close the <em>foreach()</em>, and let it go on to the next subcat.</p>
<p><strong>Finished code:</strong></p>
<pre class="brush: php">
&lt;?php $categories = get_categories(&quot;child_of=17&quot;); foreach ($categories as $cat) { ?&gt;
	&lt;div class=&quot;genre_subcat&quot;&gt;
		&lt;?php query_posts(&quot;cat=$cat-&gt;cat_ID&amp;showposts=-1&amp;order=ASC&amp;orderby=name&quot;); ?&gt;
		&lt;h2&gt;&lt;?php single_cat_title(); ?&gt;&lt;/h2&gt;
		&lt;small&gt;&lt;?php echo category_description($cat-&gt;cat_ID); ?&gt;&lt;/small&gt;
		&lt;?php while (have_posts()) : the_post(); ?&gt;
			&lt;div class=&quot;post&quot;&gt;
				&lt;h3&gt;&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; rel=&quot;bookmark&quot; title=&quot;Permanent Link to
				&lt;?php the_title_attribute(); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h3&gt;
				&lt;p class=&quot;postdate&quot;&gt;&lt;?php the_time(&#039;F jS, Y&#039;) ?&gt;&lt;/p&gt;
				&lt;?php the_content(); ?&gt;
				&lt;p class=&quot;postmetadata&quot;&gt;Posted in &lt;?php the_category(&#039;, &#039;) ?&gt; |
				&lt;?php comments_popup_link(&#039;No Comments&#039;, &#039;1 Comment&#039;, &#039;% Comments&#039;); ?&gt;&lt;/p&gt;
			&lt;/div&gt;
		&lt;?php endwhile; ?&gt;
	&lt;/div&gt;
&lt;?php }?&gt;
</pre>
<p><strong>Explanation:</strong></p>
<p>We grab an array of the category&#8217;s children, iterate through each one, make a new &#8220;genre_subcat&#8221; DIV, query the subcat, display a subcat header and description, loop through the posts with a <em>while (have_posts())</em> construct, and finally display each post in a DIV with an H3 and some metadata, all before closing the <em>while</em> and querying the next subcategory in the array.</p>
<p>Of course, this is sort of a skeleton of what you could do, but you get the idea. Yay! Sorting a category&#8217;s posts by subcategory! Yayy!!</p>
]]></content:encoded>
			<wfw:commentRss>http://iamnotagoodartist.com/how-to/wordpress-how-to-sort-category-archive-posts-by-subcategory/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
	</channel>
</rss>

