<?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 Hacks &#187; JTPratt Media</title>
	<atom:link href="http://wphacks.com/author/john-pratt/feed/" rel="self" type="application/rss+xml" />
	<link>http://wphacks.com</link>
	<description>WordPress Themes, Plugins, Hacks, Tutorials, and more!</description>
	<lastBuildDate>Sat, 19 May 2012 22:29:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>How To: Hack WordPress Theme Template Pages</title>
		<link>http://wphacks.com/how-to-hack-wordpress-theme-template-pages/</link>
		<comments>http://wphacks.com/how-to-hack-wordpress-theme-template-pages/#comments</comments>
		<pubDate>Mon, 18 May 2009 09:00:02 +0000</pubDate>
		<dc:creator>JTPratt Media</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Theme Templates]]></category>
		<category><![CDATA[WordPress Code]]></category>
		<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[WordPress How-To]]></category>
		<category><![CDATA[WordPress Tips]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=2029</guid>
		<description><![CDATA[The key to being able to display exactly what you want in WordPress is understanding WordPress theme template pages. These are the theme files that display pages, not the ones that perform functions like comments, sidebar, etc. Most of us don&#8217;t use the WordPress default theme that comes with installation, and end up downloading a [...]]]></description>
			<content:encoded><![CDATA[<p>The key to being able to display exactly what you want in WordPress is understanding WordPress theme template pages. These are the theme files that display pages, not the ones that perform functions like comments, sidebar, etc. Most of us don&#8217;t use the WordPress default theme that comes with installation, and end up downloading a free theme from the Internet. This is a great way to customize your blog, but not all theme authors code their theme the same way. The capabilities of that theme largely depend on how much time the web designer took to code it, in addition to their knowledge of WordPress itself.</p>
<p>I&#8217;m going to explain everything you need to know to be able to customize all your theme pages any way you want, and this will give you enough information to begin coding your own theme as well. Even if you&#8217;re an &#8216;expert&#8217; theme coder, you should learn something new from this article.</p>
<h3>How WordPress Works</h3>
<p>The most important thing you could learn about WordPress is the <a href="http://codex.wordpress.org/Template_Hierarchy">Template Hierarchy</a>, or &#8211; &#8220;the order in which WordPress calls pages&#8221;. The ONLY file that is required in the PHP files of any WordPress theme is the &#8220;index.php&#8221;. That&#8217;s it! That one file <em>could</em> handle every single function WordPress performs (if you wanted it to). Or, you could have a WordPress theme that had a PHP theme for for every single WP function (or anything in between).</p>
<h4>The Order of Things</h4>
<p>Every time a WordPress page is called the WP &#8216;engine&#8217;, if you will, determines (through process of elimination) what kind of page it is. It&#8217;s kind of like a &#8220;where am I?&#8221; function. WordPress says &#8220;what page am I&#8230;&#8221; and in turn tries to call pages in a specific order. If WP doesn&#8217;t find the PHP file it needs it just defaults to the &#8220;index.php&#8221; file and uses it instead. There are 9 basic kinds of pages WordPress looks for first:</p>
<p><strong>Am I the Home Page?</strong><br />
If WP thinks it&#8217;s on the home page it will look for &#8220;home.php&#8221; first, and &#8220;index.php&#8221; second.</p>
<p><strong>Am I Post Page?</strong><br />
(Single) post pages look for &#8220;single.php&#8221; first, and then default to &#8220;index.php&#8221;.</p>
<p><strong>Am I a &#8216;Paged&#8217; Page?</strong><br />
(Static) or &#8216;paged&#8217; pages in WordPress look for a &#8220;pagetemplate.php&#8221; first (if assigned when published), &#8220;page.php&#8221; second, and default to &#8220;index.php&#8221; last.</p>
<p><strong>Am I a Category Page?</strong><br />
When WordPress determines it&#8217;s on a category page first it looks like a category specific ID page, such as &#8220;category-7.php&#8221;. If it doesn&#8217;t find that it next looks for a &#8220;category.php&#8221; (which would be used on every category page). If that&#8217;s not there is searches for &#8220;archive.php&#8221;, and last it defaults to &#8220;index.php&#8221;.</p>
<p><strong>Am I a Tag Page?</strong><br />
If WordPress is on a tag page it tries to load &#8220;tag-slug.php&#8221; first, with &#8216;slug&#8217; being the name of your tag. If your tag is &#8216;wordpress hacks&#8217; the tag slug page would be &#8220;tag-wordpress-hacks.php&#8221;. It that&#8217;s not available, WP next looks for &#8220;tag.php&#8221; which would load for all tag pages, then &#8220;archive.php&#8221;, and if that&#8217;s not there last it defaults to &#8220;index.php&#8221;.</p>
<p><strong>Am I an Author Page?</strong><br />
If your blog has multiple authors, first it looks for &#8220;author.php&#8221; to display the details. If that&#8217;s not there, it tries to load &#8220;archive.php&#8221;, and last it defaults to &#8220;index.php&#8221;.</p>
<p><strong>Am I an Archive Page?</strong><br />
Archive pages are loaded when WordPress loads a date based page for previous posts. First it tries to load &#8220;date.php&#8221;, then &#8220;archive.php&#8221;, and last it defaults to &#8220;index.php&#8221;.</p>
<p><strong>Am I a Search or 404 Page?</strong><br />
If WP determines it&#8217;s on a search (results) or 404 (not found) page the it tries to load either search.php or 404.php. If not, the default is once again &#8220;index.php&#8221;.</p>
<p><strong>Am I an Attachment?</strong><br />
Out of all the WordPress theme template pages, the attachment page is probably the one used least, and I have to admit &#8211; I&#8217;ve not seen a single one of these in any of the hundreds of themes I&#8217;ve downloaded. WordPress uses these special pages usually for uploaded content, which would explain why it first looks for &#8220;image.php&#8221;, &#8220;audio.php&#8221;, &#8220;video.php&#8221;, or &#8220;application.php&#8221;. Then it tries to find &#8220;attachment.php&#8221; or &#8220;single.php&#8221;, and if none of those are available it also defaults to &#8220;index.php&#8221;.</p>
<h3>Inner Workings of WP Theme Templates</h3>
<p>As I said before, you <em>could</em> use a single index.php file to handle the 9 types of pages. You would simply code in some <a href="http://wphacks.com/wordpress-conditional-tags-hack-theme/">conditional tags</a>, like I showed you in the last tutorial I wrote here on WP Hacks. A single index.php would then just contain code to say if is_home, do this, if is_single do that, etc. That&#8217;s a lot of code for just one page, and a bit unorganized &#8211; and it doesn&#8217;t leave a lot of room for customization.</p>
<p>Coincidentally, like WordPress searches for 9 basic pages &#8211; each theme template page also contains 9 basic WordPress elements:</p>
<ol>
<li>a header call</li>
<li>opening of &#8216;the loop&#8217;</li>
<li>a call to get the permalink and (some) meta</li>
<li>a call telling WordPress what to get</li>
<li>a call to get either the content or an excerpt</li>
<li>(maybe) more meta</li>
<li>closing of &#8216;the loop&#8217;</li>
<li>a sidebar call</li>
<li>a footer call</li>
</ol>
<p>Those are only the WordPress elements, of course the PHP code to make them work is usually scattered throughout the appropriate HTML code make your theme&#8217;s layout and graphic design work properly. I&#8217;m going to explain these elements a bit more so you can understand how you can customize (or create) nearly any theme template page.</p>
<p><strong>Header, Sidebar, and Footer calls</strong></p>
<p>I&#8217;m going to handle all 3 of these elements at once, since they are all basically the same. When you see this code in a template:</p>
<p><code>&lt;?php get_header(); ?&gt;</code></p>
<p>WordPress is simply opening the &#8220;header.php&#8221; file. The same is true for get_sidebar (sidebar.php) and get_footer (footer.php). You could have multiple headers, footers, or sidebars, see the earlier link above for conditional tags.</p>
<p><strong>Opening of &#8220;the loop&#8221;</strong></p>
<p>The infamous &#8220;<a href="http://codex.wordpress.org/The_Loop">WordPress Loop</a>&#8221; is when a call goes out to the database to do something until WordPress says &#8220;stop&#8221;, i.e. &#8216;get me the most recent full text posts in their entirety&#8217;. The structure of &#8216;the loop&#8217; changes depending on what kind of page your displaying, and each of the 9 basic types of pages WordPress tries to load has a &#8216;loop&#8217;.</p>
<p>The opening of the loop generally looks like this:</p>
<p><code>&lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt;</code></p>
<p>You may see it broken down with have_posts on one line to define conditional tags with the while and the_post on another, but it&#8217;s still the opening of the loop, and it&#8217;s pretty much the same in all pages. One way to use the multi-line loop opending is to place a parameter between &#8220;if have_posts&#8221; and the rest by using <a href="http://codex.wordpress.org/Template_Tags/query_posts">query_posts</a> in between to show only a single post, posts from a time period, the last post only, posts from certain categories, or even change the ordering of posts being iterated in the loop.</p>
<p><strong>A Call to Get the Permalink and (some) meta</strong><br />
The very last section of the loop opening (the_post) actually makes individual data available through each iteration of the loop. This data referred to usually as &#8220;<a href="http://codex.wordpress.org/Post_Meta_Data_Section">post meta</a>&#8221; because it&#8217;s descriptors and identifiers for the individual content being looped through. Typically things like the permalink (URL), title, date, etc. I say &#8216;some&#8217; meta, because most themes show some things before the individual post content, and then some after &#8211; such as categories and tags.</p>
<p>Here&#8217;s a short list of things you can call in post meta: the_permalink, the_ID, the_title, the_time, the_author, the_author_email, the_author_posts_link, the_category, single_cat_title, the_tags, single_tag_titls, edit_post_link, comments_popup_link, comments_rss_link</p>
<p>Example code you might see for post meta would be something like this:</p>
<p><code>&lt;div class="post" id="post-&lt;?php the_ID(); ?&gt;"&gt;<br />
&lt;h2&gt;&lt;a href="&lt;?php the_permalink() ?&gt;" rel="bookmark"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;<br />
&lt;/div&gt;</code></p>
<p><strong>A Call Telling WP What to Get</strong><br />
Next WordPress will decide how much of the actual individual post content to get for you. How much is gathered from the database depends on whether your look uses &#8220;<a href="http://codex.wordpress.org/Template_Tags/the_content">the_content</a>&#8221; (to get it all) or &#8220;<a href="http://codex.wordpress.org/Template_Tags/the_excerpt">the_excerpt</a>&#8221; (to get part of it).</p>
<p><strong>(Maybe) more meta</strong><br />
As I previously mentioned, the common things to see after a post are assigned categories or tags, and sometimes you see an &#8220;edit&#8221; link here as well. Some themes even put date published meta after the post content.</p>
<p><strong>Closing of &#8216;the loop&#8217;</strong></p>
<p>The code looks like this:</p>
<p><code>&lt;?php else : ?&gt;<br />
&lt;?php endif; ?&gt;</code></p>
<p>Typically it&#8217;s on more than one line in case you want to build an option in, such as a message &#8220;Sorry, we didn&#8217;t find anything&#8221;. After the sidebar, before the sidebar and footer calls, is where you typically find the &#8220;next&#8221; and &#8220;previous&#8221; navigation links.</p>
<p><strong>Bastardized Loops?</strong></p>
<p>Well, just because most loops look like the examples I just gave you, doesn&#8217;t mean you can&#8217;t bastardize them in just about any way you can imagine. I recommend you read the WP Codex page <a href="http://codex.wordpress.org/The_Loop_in_Action">The Loop in Action</a> for examples of archive, category, and single post formats &#8211; as well as static home page.</p>
<p>The Codex official page for <a href="http://codex.wordpress.org/The_Loop">the loop</a> has several examples of how to place multiple loops in one page.</p>
<p>Perishable Press has a great tutorial for <a href="http://perishablepress.com/press/2008/09/01/multiple-loops-and-multiple-columns-with-wordpress/">multiple loops, multiple columns</a> &#8211; if you want to try and split your content up. They also have some great <a href="http://perishablepress.com/press/2007/11/14/easily-adaptable-wordpress-loop-templates/">loop templates</a>, in addition to a great tutorial of <a href="http://perishablepress.com/press/2008/08/04/two-column-horizontal-sequence-wordpress-post-order/">horizontally sequenced posts in two columns</a>.</p>
<h3>Conclusion</h3>
<p>Armed with just a tiny bit of knowledge, you can hack just about any WordPress theme template page to do just about whatever you want! Now that you understand (in great detail) how WordPress calls it&#8217;s pages and how the loop works, you can conquer any task! Have fun customizing your blog&#8217;s theme!</p>
<p><em>This post was submitted by John Pratt, who writes many <a href="http://www.jtpratt.com">Blogging Tips</a>, and how to create a <a href="http://www.jtpratt.com/series/wordpress-affiliate-store/">WordPress affiliate store</a>.</em></p>
<img src="http://wphacks.com/?ak_action=api_record_view&id=2029&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/how-to-hack-wordpress-theme-template-pages/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>How To: Use WordPress Conditional Tags to Hack Your Theme</title>
		<link>http://wphacks.com/wordpress-conditional-tags-hack-theme/</link>
		<comments>http://wphacks.com/wordpress-conditional-tags-hack-theme/#comments</comments>
		<pubDate>Wed, 13 May 2009 09:00:38 +0000</pubDate>
		<dc:creator>JTPratt Media</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Conditional Tags]]></category>
		<category><![CDATA[WordPress Code]]></category>
		<category><![CDATA[WordPress Conditional Tags]]></category>
		<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[WordPress How-To]]></category>
		<category><![CDATA[WordPress Tips]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=2000</guid>
		<description><![CDATA[By using simple conditional tags &#8211; it&#8217;s pretty easy to add some very basic hacks to your WordPress theme to have more control over what&#8217;s displayed when. Here are some things you could do with a conditional tags: Display something only on certain pages Display something only on certain categories Display something in header and [...]]]></description>
			<content:encoded><![CDATA[<p>By using simple conditional tags &#8211; it&#8217;s pretty easy to add some very basic hacks to your WordPress theme to have more control over what&#8217;s displayed when.</p>
<p>Here are some things you could do with a conditional tags:</p>
<ul>
<li>Display something only on certain pages</li>
<li>Display something only on certain categories</li>
<li>Display something in header and footer only at certain times</li>
<li>Display something only on sub-children of particular pages</li>
<li>Display something only in the WP dashboard</li>
<li>Display something in the sidebar only when certain conditions are met</li>
<li>Do something only when there&#8217;s a &#8220;sticky&#8221; post</li>
<li>Do something only when a &#8220;page template&#8221; is used</li>
<li>Do something only for &#8220;author pages&#8221;</li>
<li>Display something only on search or 404 pages</li>
</ul>
<p>Let&#8217;s say you want something to display only on the homepage, or just category pages, or maybe just your 404 (not found) page &#8211; it&#8217;s quite easy to do.  You don&#8217;t have to be a hardcore programmer (I&#8217;m not for sure) to implement these very simple theme hacks.</p>
<h3>Where to Use Conditional Tags</h3>
<p>It all depends on your your theme is structured.  I&#8217;ve seen WordPress themes that a single &#8220;index.php&#8221; file handle just about everything, and other ones that use only the home.php, index.php, single.php, archive.php, and category.php files.  You could handle everything with a bunch of code in one file if you want using conditional tags, have individual files for each thing, or any combination in between.  </p>
<p>Most themes I&#8217;ve encountered usually have an index.php and a single.php only.  If you want to know what pages WordPress looks for first in a theme before defaulting to the &#8220;index.php&#8221;, read the official <a href="http://codex.wordpress.org/Template_Hierarchy">WordPress Template Hierarchy</a> page.</p>
<p>Conditional tags are great because you can use them both in and out of the loop.  You can use them directly in theme pages, but you could also use them in your header, footer, comments, and sidebar files.  Actually the sky is the limit, and you have only your own imagination to limit you!</p>
<h2>Conditional Tag Examples</h2>
<p>The worst thing I see on most posts about conditional tags is that they don&#8217;t have a lot of examples for you to draw from &#8211; so I&#8217;ll try to give you a few ideas to get you started&#8230;</p>
<h3>If This is XYZ page</h3>
<p>One of the most common ways to use a conditional tag is to add a filter of sorts to tell WordPress &#8220;if I&#8217;m on &#8216;XYZ&#8217; WP page &#8211; then do this.  The most common reason would be maybe to show certain things (ads, text, messages, graphics, scripts, flash) in certain places.</p>
<p>For example, let&#8217;s say you want to display a message to visitors on your home page only&#8230;</p>
<p><code>&lt;?php if (is_home()) { ?&gt;</p>
<p>Welcome, you will only see this message on my homepage!</p>
<p>&lt;?php } ?&gt;</code></p>
<p>replace &#8220;is_home&#8221; with &#8220;is_front_page&#8221;, &#8220;is_single&#8221;, &#8220;is_sticky&#8221;, &#8220;is_page&#8221;, &#8220;is_page_template&#8221;, &#8220;is_category&#8221;, &#8220;is_tag&#8221;, &#8220;is_author&#8221;, &#8220;is_date&#8221;, &#8220;is_archive&#8221;, or &#8220;is_attachment&#8221; to make your message show up on nearly any WordPress page.  Remember, once the condition is met, you can &#8220;do&#8221; anything &#8211; from including a file to showing special graphics, running a script, anything!  You could use this condition for example to show an ad on just your homepage, or just single pages.</p>
<h3>If this is XYZ page show this, else show that</h3>
<p>The nice thing about conditional tags is the fact that you can have as many conditions as you want&#8230;like this:</p>
<p><code><br />
&lt;?php if (is_home()) { ?&gt;</p>
<p>&lt;p&gt;Show this!&lt;/p&gt;</p>
<p>&lt;?php } elseif (is_single()) { ?&gt;</p>
<p>&lt;p&gt;Show this instead!&lt;/p&gt;</p>
<p>&lt;?php } elseif (is_category()) { ?&gt;</p>
<p>&lt;p&gt;Show something different!&lt;/p&gt;</p>
<p>&lt;?php else { ?&gt;</p>
<p>&lt;p&gt;Show this if no conditions are met&lt;/p&gt;</p>
<p>&lt;?php } ?&gt;</code></p>
<p>OR &#8211; you could even structure it in such a way that you lump some conditions together like this:</p>
<p><code>&lt;?php if (is home() || is_single() || is_category() || is_page()<br />
|| is_archive() { ?&gt;</p>
<p>&lt;p&gt;Show this on all those pages!&lt;/p&gt;</p>
<p>&lt;?php } ?&gt;</code></p>
<p>The double-pipe or || in the code signifies &#8220;OR&#8221;, so WordPress knows, if this is home, or a single page, or a category page, or a &#8220;page&#8221; page, or an archive page &#8211; then so something.</p>
<h3>Show Everywhere, Except&#8230;</h3>
<p>Sometimes you want to show something everywhere possible except just one or two places&#8230;</p>
<p><code>&lt;?php if (is_home()) {<br />
}<br />
else { ?&gt;</p>
<p>&lt;p&gt;Show this everywhere!&lt;/p&gt;</p>
<p>&lt;?php } ?&gt;</code></p>
<p>With this code we just say if it&#8217;s &#8220;home&#8221; do nothing, else show do this.  You could add multiple conditions (exclusions) to this using the || OR operator as in previous examples.</p>
<h3>Getting even more specific</h3>
<p>One thing I hadn&#8217;t mentioned was that you could pass additional parameters to the conditional tags for even finer grained control.  For example, instead of targeting are single post pages with &#8220;is_single&#8221;, you could actually target just one using any of these formats:</p>
<p>is_single(&#8217;25&#8242;) // uses posts ID<br />
is_single(&#8216;Title of my post&#8217;) //uses the exact title of the post<br />
is_single(&#8216;title-of-my-post&#8217;) //uses the permalink of the post<br />
is_single(array(25,&#8217;this title&#8217;,'this permalink&#8217;)) //uses when any of the 3 are true</p>
<p>You can use similar parameters for paged pages, template pages, categories, tags, etc.  The official <a href="http://codex.wordpress.org/Conditional_Tags">WordPress Conditional Tag page</a> in the Codex lists them all.</p>
<h3>Force WordPress Functions for Certain Conditions</h3>
<p>Have you ever not wanted to add people to your blogroll because their link will display on EVERY SINGLE page of your WP powered site?  That&#8217;s an easy hack with conditional tags, because you could hack your sidebar to display your blogroll ONLY on your homepage like this:</p>
<p><code>&lt;? php if (is_home()) {<br />
  wp_list_bookmarks();<br />
  }<br />
?&gt;</code></p>
<p>You could modify this to display just about anything in the sidebar for whatever conditions you want.  Let&#8217;s take this a bit further though &#8211; let&#8217;s say that maybe I want a special header or footer when certain conditions are met?  You can do that too&#8230;</p>
<p><code>&lt;? php if (is_home() || is_single() || is_page()) {<br />
  get_header();<br />
  }<br />
elseif (is_category() || is_tag()) {<br />
  include (TEMPLATEPATH . '/header2.php');<br />
}<br />
elseif (is_404() || is_search())<br />
  include (TEMPLATEPATH . '/header3.php');<br />
} ?&gt;</code></p>
<p>Using that example code you could have as many different headers, footers, or sidebars as you wanted and you could include them for whatever conditions you specified.  Just replace get_header with get_footer or get_sidebar, and edit the rest include the files you want.</p>
<h3>Using Conditional Tags to Change Styles</h3>
<p>So far my conditional tag examples have been to show you how code conditions to do this or include that.  Another very simple (and powerful) was to use conditional tags is to just use them for coding style.  You could have any element (paragraph, div, heading) change colors or font size or anything related to style when certain conditions are met.</p>
<p>Let&#8217;s take a very simple example, maybe your pages have content contained within one div like this:</p>
<p><code>  &lt;div id="content" class="main"&gt;<br />
	&lt;?php if (have_posts()) : ?&gt;<br />
		&lt;?php while (have_posts()) : the_post(); ?&gt;<br />
		&lt;?php endwhile; ?&gt;<br />
  &lt;/div&gt;</code></p>
<p>In most themes, that main &#8220;div&#8221; is styled the same way on EVERY single page of the theme.  Maybe you want it styled one way for your homepage, but another for paged pages, single posts, archives, etc.  What you do in this case is to write different classes in your stylesheet for each and call them something like &#8220;single&#8221;, &#8220;archive&#8221;, and &#8220;paged&#8221; &#8211; and then you code it like this:</p>
<p><code>  &lt;div id="content" &lt;?php if (is_home()) { ?&gt; class="home"<br />
&lt;?php } elseif (is_page()) { ?&gt; class="paged"<br />
&lt;?php } elseif (is_single()) ?&gt; class="single"<br />
&lt;?php } elsif (is_archive()) { ?&gt; class="archive" &lt;?php } ?&gt; &gt;<br />
	&lt;?php if (have_posts()) : ?&gt;<br />
		&lt;?php while (have_posts()) : the_post(); ?&gt;<br />
		&lt;?php endwhile; ?&gt;<br />
  &lt;/div&gt;</code></p>
<p>You use any variation of this to control any element of your theme at will under nearly any condition.  This would also be a great way to control your Post title and meta and have it display different things on different parts of your WordPress powered site.</p>
<h3>Conclusion</h3>
<p>I think mostly that the power of conditional tags is widely underutilized.  Many of us just take for granted the way a theme works and looks, and forget that with just a few strokes of code and some imagination &#8211; we can change just about anything under the sun in our WordPress theme!  I&#8217;d like to see some comments on what kinds of things you&#8217;ve used conditional tags for in your WordPress site (code samples welcomed!).</p>
<p><i>This post was submitted by John Pratt, who writes about how to <a href="http://www.jtpratt.com">Make Money Blogging</a>.  His latest post is <a href="http://www.jtpratt.com/how-to-build-a-wordpress-craigslist/">How to Build a WordPress Craigslist</a>.</i></p>
<img src="http://wphacks.com/?ak_action=api_record_view&id=2000&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/wordpress-conditional-tags-hack-theme/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>10 Ways to Improve Navigation in WordPress</title>
		<link>http://wphacks.com/10-ways-to-improve-navigation-in-wordpress/</link>
		<comments>http://wphacks.com/10-ways-to-improve-navigation-in-wordpress/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 08:00:02 +0000</pubDate>
		<dc:creator>JTPratt Media</dc:creator>
				<category><![CDATA[WordPress Tips]]></category>
		<category><![CDATA[Popular Posts]]></category>
		<category><![CDATA[Related Posts]]></category>
		<category><![CDATA[WordPress Breadcrumbs]]></category>
		<category><![CDATA[WordPress Navigation]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=1234</guid>
		<description><![CDATA[This guest post was written by John Pratt who blogs about blogging, WordPress, and his life as a webmaster. If you have webmaster or WordPress knowledge and are interested in writing a post for Hack WordPress, please contact us. Improving the navigation in your blog means visitors will find MORE of your content, and return MORE [...]]]></description>
			<content:encoded><![CDATA[<p><em>This guest post was written by <a href="http://www.jtpratt.com/">John Pratt</a> who blogs about blogging, WordPress, and his life as a webmaster. If you have webmaster or WordPress knowledge and are interested in <a href="../write">writing a post for Hack WordPress</a>, please <a href="../contact">contact us</a>.</em></p>
<p><strong>Improving the navigation in your blog means visitors will find MORE of your content, and return MORE often. Even with the best content and lots of traffic &#8211; the most important thing is that people can QUICKLY find what they were looking for from the first moment they enter your blog</strong>!</p>
<p>I&#8217;m going to give you 10 different ways you can improve the navigation in your blog that anyone can (and should) implement for better usability when you have a WordPress powered blog. You will be surprised how much easier it will be to find content by using these techniques.</p>
<h3>10 Steps to Improved WordPress Navigation</h3>
<ol>
<li><strong>Add Breadcrumbs</strong>: This is a very easy fix, and one I don&#8217;t see on many blogs. Breadcrumbs are the simple link trail on the top of a web page like this: &#8220;Home -&gt; Page -&gt; SubPage&#8221;. It&#8217;s easy to add breadcrumbs, just use a 2.6+ compatible plugin like &#8220;<a href="http://mtekk.weblogs.us/code/breadcrumb-navxt/">Breadcrumb NavXT.</a></li>
<li><strong>Get rid of Ugly Next and Previous Links</strong>: Every WordPress homepage, and any page that has lists of blog posts (search, archive), has simple &#8220;next&#8221; and &#8220;previous&#8221; links to navigate older posts. I have witnessed (countless times) visitors thinking that all the posts you had to offer were listed on the homepage and that was it (mainly people not familiar with WordPress). You should have a linked list of pages (like google) that says &#8220;this is page 1 of&#8230;&#8221; and links to &#8220;2, 3, 4, 5, etc&#8221;. It&#8217;s easy to fix this with plugins like <a href="http://lesterchan.net/portfolio/programming.php">WP-PageNavi</a> or <a href="http://www.jenst.se/2008/03/29/wp-page-numbers">WP-Page Numbers.</a></li>
<li><strong>Bold Pagination on Single Pages</strong>: You can&#8217;t use the last trick on single pages, but every single (post) page has links at the bottom to view the next and previous page as well. I edit my &#8220;single.php&#8221; file to change that text to something like &#8220;Post before this one&#8221; and &#8220;Post after this one&#8221;, and align them left and right (bolded). You can style them any way you want &#8211; the point is to make them stand out. Visitors often come from SERP&#8217;s to a single post page, make it easy for them to view other ones as well.</li>
<li><strong>More Links and Excerpts</strong>: This is personal preference really, but I prefer to have post excerpts on pages instead of the entire post, because I feel it clutters up pages and makes everything run together (on most blogs). I like to encourage people to visit the single post page to read the entire thing. There are a couple ways to change a running post page (like search results, archives, index.php) to show excerpts. On your homepage, you can use the <a href="http://www.dailyblogtips.com/homepage-excerpts-wordpress-plugin/">Homepage excerpts</a> plugin to achieve this. On all other pages, just the &#8220;the loop&#8221; and change the_content to the_excerpt.</li>
<li><strong>Multi-Paged Navigation</strong>: If you ramble on like I do, some of your posts can be dreadfully long. Break them up into multi-pages posts using a plugin like <a href="http://wordpress.org/extend/plugins/multi-page-toolkit/">Multi-Page Toolkit</a>. It&#8217;s not only better usability, but it creates multiple post pages so you can get more indexed in the search engines.</li>
<li><strong>Related Posts</strong>: What better way to get people to stay on your blog than by recommending to them &#8220;related posts&#8221; that you&#8217;ve written?! All it takes is a plugin like <a href="http://www.microkid.net/wordpress/related-posts/">Related Posts.</a></li>
<li><strong>Most Viewed Posts</strong>: Like an MVP of the game &#8211; you should be showing your visitors your most valuable content! Lester Chan has a great plugin called <a href="http://rmarsh.com/plugins/random-posts/">WP Post Views</a> that has a sidebar widget than can display your most viewed posts! This is a great way to showcase your best posts and keep people on your blog.</li>
<li><strong>Most Popular Posts</strong>: Alex King has a plugin called <a href="http://alexking.org/projects/wordpress">Popularity Contest</a> that displays how popular posts are.</li>
<li><strong>Category Images</strong>: Having your categories a post is assigned to listed and linked is a great way to get visitors to view everything else you have posted in that category, but sometimes (like &#8220;ad blindness) readers are blinded to post meta info. Solve that by assigning images to your categories, so that they stand out prominently! All you need is the <a href="http://www.category-icons.com/screenshots/">Category Icons</a> plugin.</li>
<li><strong>Sidebar Navigation</strong>: There are a bazillion options for pimping out your sidebar, and most bloggers seem to just liste categories, archives, and a blogroll. Check out all of the <a href="http://codex.wordpress.org/Plugins/WordPress_Widgets">WordPress Widgets</a> available, the <a href="http://codex.wordpress.org/Customizing_Your_Sidebar">WordPress Codex page for &#8220;Customizing Your Sidebar&#8221;</a>, the <a href="http://www.mikesmullin.com/2006/06/21/list-authors-widget-10">List Authors widget</a>, <a href="http://www.damagedgoods.it/wp-plugins/parent-pages/">Parent Pages widget</a>, and especially the <a href="http://www.scratch99.com/wordpress-plugin-iframewidgets/">WordPress plugin iFrameWidgets</a>. The iframe widgets one is great if you use myBlogLog, BlogCatalog, Entrecard, or other third party widgets that may slow the load time of your blog.</li>
</ol>
<p>By following these 10 steps to better navigation, your visitors will STAY LONGER and READ MORE each and every time they visit your blog. This article was a synopsis of my in depth article <a href="http://www.jtpratt.com/wordpress-hack-5-10-ways-to-improve-navigation">WordPress Hack #5: 10 Ways to Improve Navigation</a>. Happy Hacking!</p>
<img src="http://wphacks.com/?ak_action=api_record_view&id=831&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/10-ways-to-improve-navigation-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Parsing and Hacking External RSS Feeds in WordPress</title>
		<link>http://wphacks.com/parsing-and-hacking-external-rss-feeds-in-wordpress/</link>
		<comments>http://wphacks.com/parsing-and-hacking-external-rss-feeds-in-wordpress/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 08:00:04 +0000</pubDate>
		<dc:creator>JTPratt Media</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Affiliate Marketing]]></category>
		<category><![CDATA[eBay]]></category>
		<category><![CDATA[RSS parsing]]></category>
		<category><![CDATA[WordPress Code]]></category>
		<category><![CDATA[WordPress Hacks]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=1063</guid>
		<description><![CDATA[This guest post was written by John Pratt who blogs about blogging, WordPress, and his life as a webmaster at JTPratt&#8217;s Blogging Mistakes. If you have webmaster or WordPress knowledge and are interested in writing a post for WordPress Hacks, please contact us. It&#8217;s a little known fact that WordPress contains it&#8217;s own RSS parser, [...]]]></description>
			<content:encoded><![CDATA[<p><em>This guest post was written by </em><em>John Pratt</em><em> who blogs about blogging, WordPress, and his life as a webmaster at </em><a href="http://www.jtpratt.com"><em>JTPratt&#8217;s Blogging Mistakes</em></a><em>. If you have webmaster or WordPress knowledge and are interested in </em><a href="http://wphacks.com/write/"><em>writing a post for WordPress Hacks</em></a><em>, please </em><a href="http://wphacks.com/contact"><em>contact us</em></a><em>.</em></p>
<p><strong>It&#8217;s a little known fact that WordPress contains it&#8217;s own RSS parser, and you can use it to your advantage to make custom dynamic pages!</strong></p>
<p>This is a tutorial on how to take an ordinary RSS feed, parse it using WordPress&#8217; internal RSS parser, and then create dynamic pages with it. I&#8217;m not talking about being a scraper, creating a splog, or doing anything spammy at all. I&#8217;m talking about creating added value for visitors and your blog while making money. We all know what a &#8220;splog&#8221; is. It&#8217;s a &#8220;spam blog&#8221;&#8230;or someone who takes RSS feeds and generates pages and posts from them and tries to profit using say Adsense or affiliate ads. The pages are just excerpts and titles from RSS feeds (sometimes full posts), and while they do link back to your site (usually) &#8211; they&#8217;re not the type of links you want to get. These spam blogs don&#8217;t have any redeeming value at all, no contact information, and certainly no original content at all.</p>
<p>Now &#8211; let&#8217;s take your blog, let&#8217;s say you have a birdwatching club in Buffalo, New York. You&#8217;ve developed a great site with loads of original content, bunches of articles, and your members visit regularly. The two things that you and other members talk about regularly are binoculars and digital cameras. This is what you could do&#8230;</p>
<p>Craigslist is America&#8217;s garage sale. If you don&#8217;t live in America, I&#8217;m sure something like this is in your region. Craigslist offers RSS feeds on each and every page. Here&#8217;s how the birdwatching club could benefit from that.</p>
<p>First &#8211; create a page template. From your WordPress theme directory, download &#8220;single.php&#8221; (or the theme template that creates post pages) to your desktop. Open it in Notepad or any text editor, and add the following lines of code to the top:</p>
<p><code>/* Template Name: Craigslist Template */ ?&gt; </code></p>
<p>This is the tricky part, because each and every theme is different. You need to look for the following block of code (which is what prints the page content out):</p>
<p><code>&lt;div class="entry"&gt;<br />
&lt;?php the_content(__('Read more &amp;raquo;')); ?&gt;<br />
&lt;/div&gt;</code></p>
<p>Right after those lines (or &#8220;the loop&#8221; in your template, you want to copy and paste this code:</p>
<p><code>&lt;?php include_once(ABSPATH . WPINC . '/rss.php');<br />
wp_rss('http://example.com/rss/feed/goes/here', 5); ?&gt;</code></p>
<p>That code <a href="http://codex.wordpress.org/Function_Reference/wp_rss">comes from this page in the WordPress Codex</a>. WordPress has a built in &#8220;RSS Parser&#8221; that will read any RSS feed and spit out a list of links is list ordered fashion to a page. So, if you visit the <a href="http://buffalo.craigslist.org/pho/">Buffalo Craigslist Photo page</a>, you&#8217;ll find at the bottom of the page a little orange RSS icon. Click on that link, and then copy the URL, and paste it over the example URL in your template. The number (20) that comes after the URL is the number of items from the RSS feed to parse and display. Save the template, and upload it back to your theme directory of your WordPress blog.</p>
<p>In your WordPress Dashboard, go to &#8220;Write -&gt; Page&#8221;. Type some original content in the box, and scroll down to the bottom (in WordPress 2.5, on the sidebar in &lt;2.5) and select &#8220;Craigslist Template&#8221;. Title your page &#8220;Craigslist&#8221;, and then save and publish the page. Now if you go to www.yourblog.com/craigslist you should see a listing of things from craiglist with your original content on top.</p>
<p>Look what you did, now the Buffalo Birdwatchers Club won&#8217;t can look at photo equipment right on the member web site without having to go to Craigslist unless they see an item they like. You can add multiple feeds to the same page, just copy and paste that code block in multiple times with different RSS feed URL&#8217;s. Just remember, the more your add, the longer they take to parse, and the longer the page will take to load. I loaded 6 feeds @ 20 items per feed, and the page took about 20 seconds or so to load.</p>
<p>This Craigslist example is just that &#8211; an example. If you want to see how this looks in realtime, look at <a rel="nofollow" href="http://www.ttownsound.com/craigslist">this Craiglist RSS example I just built</a>. You could use RSS feeds from just about anything, digg, google news &#8211; any site that has a feed. As long as you&#8217;re only using headline feeds and not stealing content &#8211; nobody should ever think you&#8217;re plagiarising them in any way, you&#8217;re sending them traffic. In your template file, before you parse the feeds add a few paragraphs of original content about what they user might find (on Craigslist &#8211; or whatever) and now you have a page with ever changing (daily) content, AND orignal content that google can index!</p>
<p>Now, how do you monetize this? Well, use your noggin and add some affiliate banners, adsense, or other items above, below, or in your sidebar. There is a better way to monetize without using these though&#8230;</p>
<p>eBay has RSS feeds &#8211; don&#8217;t they?  All you have to do is add your affiliate code to an eBay RSS feed, and you could use it instead of the Craigslist feed for a list of eBay items, and every time someone clicks, bids, and buys an auction you profit! First you have to be a member of the <a href="http://affiliates.ebay.com">eBay Partner Network (EPN)</a>. Once logged in go to &#8220;Tools-&gt;Widgets-&gt;RSS Feed Generator&#8221;. Then just enter in what you&#8217;re looking for. Like Craigslist, you can &#8220;geo-target&#8221; what you want by scrolling down and checking &#8220;Items within 50 miles of xxxxx zip code&#8221;. Then click &#8220;search&#8221; and the page you get should be auctions for only that area. Again, scroll to the bottom of the page and see the orange RSS icon. Click on it and copy the URL and use that as the URL in the code block in your template, save the page now your blog page will list eBay auctions! The difference between these listings and Craigslist is that you profit from each won auction click on these.</p>
<p>I&#8217;ve just given you a few ideas, the sky&#8217;s the limit with these. You could probably do the exact same thing with Amazon. Now, there&#8217;s one thing I didn&#8217;t tell you, often people want to know how to take an RSS feed an automatically create blog posts from the feed and publish them, kind of like what&#8217;s called an &#8220;auto-blog&#8221;. Let me state first that there are very few legit reasons to do this, because of duplicate content issues in google, etc. Most people want to use this to try and create quick spammy blogs with no original content, but there are (just a very few) legit reasons to want to create posts from an RSS feed (like doing a blogroll type page for members of a larger community). You can do that easily (and freely) with <a href="http://projects.radgeek.com/feedwordpress/">RadGeek&#8217;s Feed WordPress Plugin</a></p>
<p>Now, get hacking, come back to comment and tell me what you&#8217;ve come up with!</p>
<img src="http://wphacks.com/?ak_action=api_record_view&id=667&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/parsing-and-hacking-external-rss-feeds-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>How To: Making Your Old WordPress Posts New Again</title>
		<link>http://wphacks.com/how-to-make-old-wordpress-posts-new-again/</link>
		<comments>http://wphacks.com/how-to-make-old-wordpress-posts-new-again/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 08:00:42 +0000</pubDate>
		<dc:creator>JTPratt Media</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress How-To]]></category>
		<category><![CDATA[WordPress Posts]]></category>
		<category><![CDATA[WordPress Tips]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=857</guid>
		<description><![CDATA[This guest post was written by John Pratt who blogs about blogging, WordPress, and his life as a webmaster. If you have webmaster or WordPress knowledge and are interested in writing a post for Hack WordPress, please contact us. There are a lot of unethical &#8220;content spinning&#8221; plugins for WordPress and other blogging platforms on the [...]]]></description>
			<content:encoded><![CDATA[<p><em>This guest post was written by <a href="http://www.lyxia.org/"></a><a href="http://www.jtpratt.com/">John Pratt</a> who blogs about blogging, WordPress, and his life as a webmaster. If you have webmaster or WordPress knowledge and are interested in <a href="../write">writing a post for Hack WordPress</a>, please <a href="../contact">contact us</a>.</em></p>
<p><em></em>There are a lot of unethical &#8220;content spinning&#8221; plugins for WordPress and other blogging platforms on the web. But for those of us with legitimate blogs, after about 100 posts your content starts to get lost. Most of it is still good, and most of us have multiple blogs as well. Why not &#8220;bring back&#8221; a post from the archive to the home page on a regular schedule and reuse that old content again? Before I had this plugin I longed for something that would effectively rotate my blog posts out of the archives and back onto the front page of my blog. Not every blog will have a need for this, but I have quite a few blogs, and I can&#8217;t always work on every one every day (or even every week). The blog paradigm means that the newest things are on the homepage scrolling down to the oldest, and when the content doesn&#8217;t change it makes you blog &#8220;stale&#8221;.</p>
<p>Being able to recycle your blog posts takes a marketing tip from fast food restaurants. Do you ever notice that certain things &#8220;come back&#8221; on a regular basis? Every year for Lent, all the fast food restaurants being back the &#8220;fish sandwich&#8221;. You see McDonald&#8217;s bring back the &#8220;McRib&#8221; and the &#8220;Monopoly Game&#8221; about once per year. They take things in and out of the rotation to keep it fresh, and if your blog posts stand the test of time, there&#8217;s no reason that they can&#8217;t be rotated too.</p>
<p>I have a fun site called &#8220;<a href="http://www.topjokes.info">Top Jokes</a> that&#8217;s been live with jokes for about 8 months or so. I used to posts a joke or more every day, in fact there are now more than 500 jokes. This type of site doesn&#8217;t pay very well, as far as a CTR, and the traffic isn&#8217;t so high either. But I don&#8217;t want to get rid of it because like all web real estate &#8220;it grows over time&#8221; &#8211; I just want to minimize the amount of time I spend on it. I&#8217;d like to post maybe a half dozen jokes per month and rotate old jokes from the archives to the homepage at the rate of one per day.</p>
<p>Enter the brilliant plugin by Dagon Design <a href="http://www.dagondesign.com/articles/scheduled-post-shift-plugin-for-wordpress/">Scheduled Post Shift Plugin for WordPress</a>. It&#8217;s a very simple, very easy to use plugin. Once you install and enable it &#8211; just set the options:</p>
<p><img src="http://www.jtpratt.com/wp-content/images/scheduled-post-shift-options.gif" alt="scheduled post shift options" /></p>
<p>Just enter the number of hours between post shifts, and at that time it will rotate your oldest post in your WordPress blog to your home page by changing the published date to current time. Once per day enter 24 hours, twice per day 12 hours, every two days enter 48 hours, etc. The second option you can leave blank, but if you enter a category ID only posts from that category will be rotated. You could use this to your advantage in an interesting way by creating a dozen or so posts, and give them dates from a year ago and assign them to a &#8220;sponsors&#8221; category. Then enable Scheduled Posts Shift for just the &#8220;sponsors&#8221; category every 24 hours (if you post every day) or whatever your post schedule is to have &#8220;recommended&#8221; or sponsored items cycle through your home page regularly. This could be a very interesting way to monetize your blog.</p>
<p>However you use it, Scheduled Posts Shift can help you to automatically recycle your WordPress blog posts and keep all that hard work and those archives you&#8217;ve built up over time producing both traffic and income for years!</p>
<p>If by chance you&#8217;re using data based permalinks &#8211; will need to remove them and use just the post (/%post%) so the URL of your posts doesn&#8217;t change when the old posts are &#8220;shifted&#8221; to the home page. Read <a href="http://www.jtpratt.com/wordpress-hack-12-changing-permalink-structure-seamlessly/">How to change permalink structure seamlessly</a> if that situation applies to you.</p>
<img src="http://wphacks.com/?ak_action=api_record_view&id=526&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/how-to-make-old-wordpress-posts-new-again/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

