<?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; Hacks</title>
	<atom:link href="http://wphacks.com/category/hacks/feed/" rel="self" type="application/rss+xml" />
	<link>http://wphacks.com</link>
	<description>WordPress Themes, Plugins, Hacks, Tutorials, and more!</description>
	<lastBuildDate>Sun, 28 Feb 2010 15:36:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Page Sensitive Multi-Level Navigation</title>
		<link>http://wphacks.com/page-sensitive-multi-level-navigation/</link>
		<comments>http://wphacks.com/page-sensitive-multi-level-navigation/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 15:56:01 +0000</pubDate>
		<dc:creator>V Scott Ellis</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[WordPress Code]]></category>
		<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[WordPress Navigation]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=2409</guid>
		<description><![CDATA[While most sites don&#8217;t need incredibly deep page navigation there are situations that justify a hierarchy beyond the typical 2 &#8211; 3 levels.  Unfortunately that can be cumbersome for top navigation drop-downs (more than 1 level of drop down is too much IMHO) so another solution needs to be found.  I ran into just such [...]]]></description>
			<content:encoded><![CDATA[<p>While most sites don&#8217;t need incredibly deep page navigation there are situations that justify a hierarchy beyond the typical 2 &#8211; 3 levels.  Unfortunately that can be cumbersome for top navigation drop-downs (more than 1 level of drop down is too much IMHO) so another solution needs to be found.  I ran into just such a situation for a client and while I&#8221;m also not a fan of left hand navigation it was the decision of the client to utilize it in conjunction with their top navigation, and in retrospect it made sense for them. To keep things easily navigable we also implemented breadcrumbs (which is a good practice anyway).</p>
<p>The mission was to display sub-pages of the current page you are on in the left nav and once you hit the bottom of the hierarchy to show pages which are parallel to that page within the same branch of the hierarchy.</p>
<p>After some digging and experimentation I came up with the following which executes perfectly in only a few lines of code.</p>
<p><code>&lt;?php<br />
$children = wp_list_pages("title_li=&amp;child_of=".$post-&gt;ID."&amp;echo=0&amp;depth=1");<br />
if ($children == "")<br />
$children = wp_list_pages("title_li=&amp;child_of=".$post-&gt;post_parent."&amp;echo=0&amp;depth=1");<br />
?&gt;<br />
&lt;ul&gt;<br />
&lt;?php echo $children; ?&gt;<br />
&lt;/ul&gt;<br />
&lt;?php endif; ?&gt;</code></p>
<p>Of course you style to taste&#8230;</p>
<p>That&#8217;s it! Used in conjunction with a standard WordPress top-navigation and breadcrumbs you can easily display page sensitive multi-level navigation for your super-complex multi-level site!</p>
<img src="http://wphacks.com/?ak_action=api_record_view&id=2409&type=feed" alt="" /><p>You are reading <a href="http://wphacks.com/page-sensitive-multi-level-navigation/">Page Sensitive Multi-Level Navigation</a>  © 2009 | <a href="http://wphacks.com">WordPress Hacks</a> | <a href="http://wpnexus.com">WordPress Directory</a> | <a href="http://wpforums.com/">WordPress Forums</a> | <a href="http://wpebook.com/">WordPress eBook</a></p>

<p><small>Enjoy writing about WordPress?  Get your blog more exposure by joining the <a href="http://wphacks.com/write/">WordPress Hacks writing team</a>!</small></p>]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/page-sensitive-multi-level-navigation/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Security Reminder: Upgrading Your WordPress Blogs</title>
		<link>http://wphacks.com/security-reminder-upgrading-your-wordpress-blogs/</link>
		<comments>http://wphacks.com/security-reminder-upgrading-your-wordpress-blogs/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 20:40:21 +0000</pubDate>
		<dc:creator>Kyle Eslick</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Upgrade WordPress]]></category>
		<category><![CDATA[WordPress Blogs]]></category>
		<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[WordPress Security]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=2339</guid>
		<description><![CDATA[While I was away over the weekend, it appears that a large number of bloggers who use WordPress have been hacked and a lot of damage has been done.  It seems this problem has shown up for a large number of people, including some very high profile bloggers.  Among them was Robert Scoble, whose blog [...]]]></description>
			<content:encoded><![CDATA[<p>While I was away over the weekend, it appears that a large number of bloggers who use WordPress have been hacked and a lot of damage has been done.  It seems this problem has shown up for a large number of people, including some very high profile bloggers.  Among them was <a href="http://scobleizer.com/2009/09/05/i-dont-feel-safe-with-wordpress-hackers-broke-in-and-took-things/">Robert Scoble</a>, whose blog was among those websites which were hacked.   Damages on Scoble&#8217;s site included porn information being placed in old posts, 2 entire months of content being deleted, and more.  Of course the porn then led to his blog being completely banned from Google!   Scoble is not the only one having these problems, however, and even lesser known bloggers have been attacked.  You can read more in this <a href="http://wordpress.org/support/topic/307518">WordPress support forum thread</a>.</p>
<p>If you are wondering what the one thing all of these WordPress sites have in common, the problem is they were all using old versions of WordPress.   As someone that owns and operates well over 100 WordPress installations, I certainly understand the pain it can be to upgrade to the latest version of WordPress every time a new release happens, but I hope this goes to show why it is so important to take the time to upgrade all of your WordPress installations be using the most recent version of WordPress.</p>
<img src="http://wphacks.com/?ak_action=api_record_view&id=2339&type=feed" alt="" /><p>You are reading <a href="http://wphacks.com/security-reminder-upgrading-your-wordpress-blogs/">Security Reminder: Upgrading Your WordPress Blogs</a>  © 2009 | <a href="http://wphacks.com">WordPress Hacks</a> | <a href="http://wpnexus.com">WordPress Directory</a> | <a href="http://wpforums.com/">WordPress Forums</a> | <a href="http://wpebook.com/">WordPress eBook</a></p>

<p><small>Enjoy writing about WordPress?  Get your blog more exposure by joining the <a href="http://wphacks.com/write/">WordPress Hacks writing team</a>!</small></p>]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/security-reminder-upgrading-your-wordpress-blogs/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Separating Trackbacks from Comments in WordPress 2.7+</title>
		<link>http://wphacks.com/separating-trackbacks-from-comments-in-wordpress-2-7/</link>
		<comments>http://wphacks.com/separating-trackbacks-from-comments-in-wordpress-2-7/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 15:39:11 +0000</pubDate>
		<dc:creator>Kyle Eslick</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Seperating Trackbacks from Comments]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress 2.7]]></category>
		<category><![CDATA[WordPress Code]]></category>
		<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[WordPress How-To]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=2287</guid>
		<description><![CDATA[Back when WordPress 2.7 was released, the WordPress team introduced a completely revamped comment form that included integration of threaded comments into the core software, introducing some dramatic changes with how comments are handled.   Unfortunately, this change broke one of the most popular comment hacks, separating trackbacks from comments.
Since then, several people have stepped up [...]]]></description>
			<content:encoded><![CDATA[<p>Back when <a href="http://wphacks.com/wordpress-27-now-available-for-download/">WordPress 2.7 was released</a>, the WordPress team introduced a completely revamped comment form that included integration of threaded comments into the core software, introducing some dramatic changes with how comments are handled.   Unfortunately, this change broke one of the most popular comment hacks, <a href="http://wphacks.com/how-to-separate-wordpress-comments-and-trackbacks/">separating trackbacks from comments</a>.</p>
<p>Since then, several people have stepped up and shared some great hacks for separating trackbacks from comment in WordPress 2.7 or newer blogs .  So far the best guide I&#8217;ve found came from Sivel.net, which can be viewed <a href="http://sivel.net/2008/10/wp-27-comment-separation/">here</a>.  Click over and follow those steps get everything separated.</p>
<p><em>Note: The above guide is only for people using WordPress 2.7 or newer installations.  For people using WordPress 2.6 or earlier, you&#8217;ll want to use <a href="http://wphacks.com/how-to-separate-wordpress-comments-and-trackbacks/">this tutorial</a>.</em></p>
<p>Once you&#8217;ve got the comments successfully separated from the trackbacks, there are a couple additional tweaks you may want to do to clean up how things look (it really depends on preference I suppose).   The first is to clean up your trackbacks/pingbacks by only displaying the title instead of an excerpt and everything else.   In order to do this, you&#8217;ll need to find the following code in your comments.php file:</p>
<p><code>&lt;ol&gt;<br />
&lt;?php wp_list_comments('type=pings'); ?&gt;<br />
</code></p>
<p>Now <strong>replace</strong> that code with the following:</p>
<p><code>&lt;ol&gt;<br />
&lt;?php wp_list_comments('type=pings&amp;callback=list_pings'); ?&gt;<br />
</code></p>
<p>Lastly, you&#8217;ll need to add the following code to your functions.php file (which can be created if you don&#8217;t already have one):</p>
<p><code>&lt;?php<br />
function list_pings($comment, $args, $depth) {<br />
$GLOBALS['comment'] = $comment;<br />
?&gt;<br />
&lt;li id="comment-&lt;?php comment_ID(); ?&gt;"&gt;&lt;?php comment_author_link(); ?&gt;<br />
&lt;?php } ?&gt;<br />
</code></p>
<p>That should clean up the trackbacks/pingbacks section and you can also apply the same changes if you use a plugin to display tweetbacks.</p>
<p>The other thing you may want to do is fix the comment count to only show actual comments, filtering out the trackbacks/pingbacks which are included in your comment count by default.   Simply add the following code to your functions.php file (which again can be created if you don&#8217;t already have one):</p>
<p><code>&lt;?php<br />
add_filter('get_comments_number', 'comment_count', 0);<br />
function comment_count( $count ) {<br />
if ( ! is_admin() ) {<br />
global $id;<br />
$comments_by_type = &amp;separate_comments(get_comments('status=approve&amp;post_id=' . $id));<br />
return count($comments_by_type['comment']);<br />
} else {<br />
return $count;<br />
}<br />
}<br />
?&gt;<br />
</code></p>
<p>So there you go.  Anyone have any other tips for cleaning up your comment form?</p>
<img src="http://wphacks.com/?ak_action=api_record_view&id=2287&type=feed" alt="" /><p>You are reading <a href="http://wphacks.com/separating-trackbacks-from-comments-in-wordpress-2-7/">Separating Trackbacks from Comments in WordPress 2.7+</a>  © 2009 | <a href="http://wphacks.com">WordPress Hacks</a> | <a href="http://wpnexus.com">WordPress Directory</a> | <a href="http://wpforums.com/">WordPress Forums</a> | <a href="http://wpebook.com/">WordPress eBook</a></p>

<p><small>Enjoy writing about WordPress?  Get your blog more exposure by joining the <a href="http://wphacks.com/write/">WordPress Hacks writing team</a>!</small></p>]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/separating-trackbacks-from-comments-in-wordpress-2-7/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>How to: Use Thumbnails Generated by WordPress</title>
		<link>http://wphacks.com/how-to-use-thumbnails-generated-by-wordpress/</link>
		<comments>http://wphacks.com/how-to-use-thumbnails-generated-by-wordpress/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 15:25:11 +0000</pubDate>
		<dc:creator>Alex Denning</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Media]]></category>
		<category><![CDATA[WordPress Code]]></category>
		<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[WordPress Tips]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=2183</guid>
		<description><![CDATA[One of ten brilliant tips that I shared yesterday on my blog &#8211; display images on your blog&#8217;s homepage without any custom fields or any additional functions.php script, something I first saw on  WebDeveloperPlus.
How do you do it? First log in, on the sidebar select &#8216;Media&#8217; (which is under &#8216;Settings&#8217;). You&#8217;ll then be taken to [...]]]></description>
			<content:encoded><![CDATA[<p>One of ten brilliant tips that <a href="http://wpshout.com/10-tips-to-improve-your-wordpress-theme/">I shared yesterday on my blog</a> &#8211; display images on your blog&#8217;s homepage without any custom fields or any additional functions.php script, something I first saw on  <a href="http://webdeveloperplus.com/wordpress/how-to-use-thumbnails-generated-by-wordpress-in-your-theme/">WebDeveloperPlus</a>.</p>
<p>How do you do it? First log in, on the sidebar select &#8216;Media&#8217; (which is under &#8216;Settings&#8217;). You&#8217;ll then be taken to a page with an option to change the thumbnail size of images. Change that to whatever size you want your images to appear as. Next, insert the code below onto your homepage, archive page, whatever.</p>
<p><code>&lt;?php<br />
//Get images attached to the post<br />
$args = array(<br />
'post_type' =&gt; 'attachment',<br />
'post_mime_type' =&gt; 'image',<br />
'numberposts' =&gt; -1,<br />
'order' =&gt; 'ASC',<br />
'post_status' =&gt; null,<br />
'post_parent' =&gt; $post-&gt;ID<br />
);<br />
$attachments = get_posts($args);<br />
if ($attachments) {<br />
foreach ($attachments as $attachment) {<br />
$img = wp_get_attachment_thumb_url( $attachment-&gt;ID );<br />
break; }<br />
//Display image<br />
} ?&gt;<br />
</code></p>
<p>Then, to display your image you can just echo out the $img tag we just created:</p>
<p><code>&lt;img src="&lt;?php echo $img; ?&gt;" alt=" " /&gt;<br />
</code><br />
And there we have it. I told you it was easy! This is one of the tips from a post I wrote yesterday on WPShout &#8211; &#8216;<a href="http://wpshout.com/10-tips-to-improve-your-wordpress-theme/">10 Tips to Improve Your WordPress Theme</a>&#8216;.</p>
<img src="http://wphacks.com/?ak_action=api_record_view&id=2183&type=feed" alt="" /><p>You are reading <a href="http://wphacks.com/how-to-use-thumbnails-generated-by-wordpress/">How to: Use Thumbnails Generated by WordPress</a>  © 2009 | <a href="http://wphacks.com">WordPress Hacks</a> | <a href="http://wpnexus.com">WordPress Directory</a> | <a href="http://wpforums.com/">WordPress Forums</a> | <a href="http://wpebook.com/">WordPress eBook</a></p>

<p><small>Enjoy writing about WordPress?  Get your blog more exposure by joining the <a href="http://wphacks.com/write/">WordPress Hacks writing team</a>!</small></p>]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/how-to-use-thumbnails-generated-by-wordpress/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<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>John Pratt</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 &#8217;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 &#8217;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="" /><p>You are reading <a href="http://wphacks.com/how-to-hack-wordpress-theme-template-pages/">How To: Hack WordPress Theme Template Pages</a>  © 2009 | <a href="http://wphacks.com">WordPress Hacks</a> | <a href="http://wpnexus.com">WordPress Directory</a> | <a href="http://wpforums.com/">WordPress Forums</a> | <a href="http://wpebook.com/">WordPress eBook</a></p>

<p><small>Enjoy writing about WordPress?  Get your blog more exposure by joining the <a href="http://wphacks.com/write/">WordPress Hacks writing team</a>!</small></p>]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/how-to-hack-wordpress-theme-template-pages/feed/</wfw:commentRss>
		<slash:comments>10</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>John Pratt</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 footer only at certain [...]]]></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(&#8216;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="" /><p>You are reading <a href="http://wphacks.com/wordpress-conditional-tags-hack-theme/">How To: Use WordPress Conditional Tags to Hack Your Theme</a>  © 2009 | <a href="http://wphacks.com">WordPress Hacks</a> | <a href="http://wpnexus.com">WordPress Directory</a> | <a href="http://wpforums.com/">WordPress Forums</a> | <a href="http://wpebook.com/">WordPress eBook</a></p>

<p><small>Enjoy writing about WordPress?  Get your blog more exposure by joining the <a href="http://wphacks.com/write/">WordPress Hacks writing team</a>!</small></p>]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/wordpress-conditional-tags-hack-theme/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>How To: Prevent Images from Being to Large</title>
		<link>http://wphacks.com/how-to-prevent-images-from-being-to-large/</link>
		<comments>http://wphacks.com/how-to-prevent-images-from-being-to-large/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 17:09:51 +0000</pubDate>
		<dc:creator>Kyle Eslick</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS Techniques]]></category>
		<category><![CDATA[WordPress Code]]></category>
		<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[Wordpress Images]]></category>
		<category><![CDATA[WordPress Themes]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=1904</guid>
		<description><![CDATA[Have you ever had an image show up on your website which is to large, causing problems for your WordPress theme?   This is especially common for WordPress blogs that have multiple authors, where some authors or guest posters may not know how big they can make the images.
Fixing this is incredibly easy with this CSS [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever had an image show up on your website which is to large, causing problems for your WordPress theme?   This is especially common for WordPress blogs that have multiple authors, where some authors or guest posters may not know how big they can make the images.</p>
<p>Fixing this is incredibly easy with this CSS hack!    All you need to do is take the following code and place it in your stylesheet, setting a maximum width for your images:</p>
<p><code>.postarea img {<br />
max-width: 500px;<br />
height: auto;<br />
}</code></p>
<p>In the above code snippet, you&#8217;ll want to replace postarea with whatever div ID or CLASS your theme uses for the content.   You can also adjust the 500px to the maximum width you&#8217;d like for your images to be.</p>
<p><strong>Note:</strong> This hack may not work on some versions of Internet Explorer.</p>
<img src="http://wphacks.com/?ak_action=api_record_view&id=1904&type=feed" alt="" /><p>You are reading <a href="http://wphacks.com/how-to-prevent-images-from-being-to-large/">How To: Prevent Images from Being to Large</a>  © 2009 | <a href="http://wphacks.com">WordPress Hacks</a> | <a href="http://wpnexus.com">WordPress Directory</a> | <a href="http://wpforums.com/">WordPress Forums</a> | <a href="http://wpebook.com/">WordPress eBook</a></p>

<p><small>Enjoy writing about WordPress?  Get your blog more exposure by joining the <a href="http://wphacks.com/write/">WordPress Hacks writing team</a>!</small></p>]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/how-to-prevent-images-from-being-to-large/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How To: Update Your WordPress Database Name</title>
		<link>http://wphacks.com/how-to-update-your-wordpress-database/</link>
		<comments>http://wphacks.com/how-to-update-your-wordpress-database/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 09:00:14 +0000</pubDate>
		<dc:creator>Kyle Eslick</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[CPanel]]></category>
		<category><![CDATA[Moving Database]]></category>
		<category><![CDATA[WordPress Database]]></category>
		<category><![CDATA[WordPress Server]]></category>
		<category><![CDATA[wp-config.php]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=1825</guid>
		<description><![CDATA[Last week while I was doing some spring cleaning, I decided to move a few of my sites over to a new CPanel.   The move went fairly smoothly, but once everything was moved, there was the matter of updating the WordPress database to show the new database name. If you are wanting to do something [...]]]></description>
			<content:encoded><![CDATA[<p>Last week while I was doing some <a href="http://wphacks.com/computer-spring-cleaning-tips/">spring cleaning</a>, I decided to move a few of my sites over to a new CPanel.   The move went fairly smoothly, but once everything was moved, there was the matter of updating the WordPress database to show the new database name. If you are wanting to do something similar, here is what you need to do.</p>
<p>All you need to do is update the wp-config.php file to point towards the new database name, which should be found in the root of your WordPress installation.   Open the wp-config.php file and look for the following code:</p>
<p><code>define('DB_NAME', 'dbname');</code></p>
<p>Where it says dbname, update the name of your database.  If your login name changed, you&#8217;ll want to update that as well.</p>
<p>Once that was done, the only problem I encountered was that I was unable to upload pictures.   The fix?  Go into your WordPress dashboard and go to Settings &#8211;&gt; Miscellaneous and update the path where images are uploaded to.</p>
<img src="http://wphacks.com/?ak_action=api_record_view&id=1825&type=feed" alt="" /><p>You are reading <a href="http://wphacks.com/how-to-update-your-wordpress-database/">How To: Update Your WordPress Database Name</a>  © 2009 | <a href="http://wphacks.com">WordPress Hacks</a> | <a href="http://wpnexus.com">WordPress Directory</a> | <a href="http://wpforums.com/">WordPress Forums</a> | <a href="http://wpebook.com/">WordPress eBook</a></p>

<p><small>Enjoy writing about WordPress?  Get your blog more exposure by joining the <a href="http://wphacks.com/write/">WordPress Hacks writing team</a>!</small></p>]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/how-to-update-your-wordpress-database/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>How To: Add Images to WordPress Login/Register links</title>
		<link>http://wphacks.com/how-to-add-images-wordpress-login-register-links/</link>
		<comments>http://wphacks.com/how-to-add-images-wordpress-login-register-links/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 09:00:44 +0000</pubDate>
		<dc:creator>Arian Xhezairi</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[WordPress Code]]></category>
		<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[WordPress How-To]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=1819</guid>
		<description><![CDATA[Have you ever wanted to use icons/images instead of plain text for Login/Register links on a WordPress blog?   Thankfully WordPress allows a down to bone customization so you could say that   almost everything is possible. Our technique is simply achieved by creating two functions and adding them to your   [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever wanted to use icons/images instead of plain text for Login/Register links on a <a href="http://www.wordpress.org/">WordPress</a> blog?   Thankfully WordPress allows a down to bone customization so you could say that   almost everything is possible. Our technique is simply achieved by creating two functions and adding them to your   theme’s <em>function.php</em> file.</p>
<p>To replace Log in/Log Out text with a desired image, simply copy the code below and make your <em>functions.php</em> file ready for editing (through WordPress Theme Editor or FTP),</p>
<p><code>//Image instead of text for the "Login &amp; Log Out" links<br />
function ax_login() {<br />
$before = '&lt;li class="axLinks"&gt;';<br />
$after = '&lt;/li&gt;';<br />
$theme_url = get_bloginfo('template_url');<br />
if ( ! is_user_logged_in() )<br />
$link = $before . '&lt;a href="' . wp_login_url() . '"&gt;' . '&lt;img src="' . $theme_url . '/images/login.png"   alt="Log in" /&gt;' . '&lt;/a&gt;' . $after;<br />
else<br />
$link = $before . '&lt;a href="' . wp_logout_url() . '"&gt;' . '&lt;img src="' . $theme_url . '/images/logout.png" alt="Log Out" /&gt;' . '&lt;/a&gt;' . $after;<br />
echo apply_filters('loginout', $link);<br />
}</code></p>
<p>Paste the code you copied and then submit/save the file. Pick two icons you   like (<em>the size it’s up to you to decide but names are relative to the code, see: login.png, logout.png</em>) and upload them to your theme <em>images</em> folder. Reload your WP site and ta-da!!! There you see two new shiny icons you didn’t have before. This code applies to any situation, whether you do have or not the Meta Widget active.</p>
<p><em><strong>What just happened?</strong></em></p>
<p>This function will override the output of <em>loginout</em> filter, it   requires you to have <strong><a href="http://codex.wordpress.org/Template_Tags/wp_loginout" target="_blank">wp_loginout();</a></strong> somewhere on  your theme   where you want to show your login icon. You can even style it using <em>CSS</em> by adding the .axLinks{ } class to your theme’s style.css file, and then manipulate it as you desire. Here’s a small CSS block which gives only basic directions.</p>
<p><code>.axLinks li, a, img{<br />
background-color: transparent;<br />
list-style: none;<br />
text-decoration: none;<br />
border: 0;  }</code></p>
<p>The same treatment can be applied to the <em>register</em> filter as well, with just some small necessary changes, of course a new functions needs to be created only to avoid confusion. Below you can find the code for Register/Site Admin links. Follow the same steps as with the function above.</p>
<p><code>//Image instead of text for the "Register &amp; Site Admin" links<br />
function ax_register() {<br />
$before = '&lt;li class="axLinks"&gt;';<br />
$after = '&lt;/li&gt;';<br />
$theme_url = get_bloginfo('template_url');<br />
if ( ! is_user_logged_in() ) {<br />
if (   get_option('users_can_register') )<br />
$link = $before . '&lt;a href="' . site_url('wp-login.php?action=register', 'login') . '"&gt;' . '&lt;img src="' . $theme_url . '/images/register.png" alt="Register" /&gt;' .   '&lt;/a&gt;' . $after;<br />
}   else {<br />
$link = $before . '&lt;a href="' . admin_url() . '"&gt;' . '&lt;img src="' .$theme_url . '/images/site_admin.png" alt="Site Admin" /&gt;' .   '&lt;/a&gt;' . $after;<br />
}<br />
echo apply_filters('register', $link);<br />
}</code></p>
<p>This function will override the output of <em>register</em> filter, it   requires you to have <strong><a href="http://codex.wordpress.org/Template_Tags/wp_register">wp_register();</a></strong> somewhere on  your theme, more precisely wherever you want your register/site admin icon. Now if you don’t have any pre-chosen icons, there are numerous choices <a href="http://www.google.com/search?hl=en&amp;q=download+free+icons&amp;btnG=Search">out there</a>.</p>
<p>This little modification has been tried and proven to work up to WordPress.2.7.1 and is intended to save you from editing the core, instead creating two easy-to-customize functions that can be delivered with your theme. If you encounter any potential problems feel free to ask by commenting below.  Cheers!</p>
<p><em>This was a guest post by Arian Xhezairi, a WordPress manic, web developer and Twitter user (<a rel="nofollow" href="http://twitter.com/arianxhezairi">follow him here</a>!). You can also check out his site,   <a href="http://itechnologize.net/">iTechnologize.net</a>. If you have WordPress knowledge and are interested in writing   a post for WordPress Hacks, please <a href="http://wphacks.com/contact/">contact us</a>.</em></p>
<img src="http://wphacks.com/?ak_action=api_record_view&id=1819&type=feed" alt="" /><p>You are reading <a href="http://wphacks.com/how-to-add-images-wordpress-login-register-links/">How To: Add Images to WordPress Login/Register links</a>  © 2009 | <a href="http://wphacks.com">WordPress Hacks</a> | <a href="http://wpnexus.com">WordPress Directory</a> | <a href="http://wpforums.com/">WordPress Forums</a> | <a href="http://wpebook.com/">WordPress eBook</a></p>

<p><small>Enjoy writing about WordPress?  Get your blog more exposure by joining the <a href="http://wphacks.com/write/">WordPress Hacks writing team</a>!</small></p>]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/how-to-add-images-wordpress-login-register-links/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Collection of WordPress Comment Hacks</title>
		<link>http://wphacks.com/collection-of-wordpress-comment-hacks/</link>
		<comments>http://wphacks.com/collection-of-wordpress-comment-hacks/#comments</comments>
		<pubDate>Sat, 14 Feb 2009 08:00:02 +0000</pubDate>
		<dc:creator>Kyle Eslick</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[WordPress Comments]]></category>
		<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[WordPress How-To]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=1780</guid>
		<description><![CDATA[There are all sorts of WordPress hacks people can easily do to customize and improve both the look and functionality of their WordPress blog, but I&#8217;ve always felt that the comments section is one of the best ways to truly customize your WordPress theme.   After all, blogging is all about author interaction, and the comments [...]]]></description>
			<content:encoded><![CDATA[<p>There are all sorts of <a href="http://wphacks.com/wordpress-hacks/">WordPress hacks</a> people can easily do to customize and improve both the look and functionality of their WordPress blog, but I&#8217;ve always felt that the comments section is one of the best ways to truly customize your WordPress theme.   After all, blogging is all about author interaction, and the comments go a long way towards conversations happening.</p>
<p>If you are looking to improve the comments field of your blog&#8217;s theme, Instant Shift recently took the time to feature a number of comment hacks, which can be viewed <a rel="nofollow" href="http://www.instantshift.com/2009/02/08/30-most-wanted-wordpress-comments-page-hacks/">here</a>.   Looks like they&#8217;ve already got 30 hacks included, including a few we&#8217;ve featured here in the past.</p>
<img src="http://wphacks.com/?ak_action=api_record_view&id=1780&type=feed" alt="" /><p>You are reading <a href="http://wphacks.com/collection-of-wordpress-comment-hacks/">Collection of WordPress Comment Hacks</a>  © 2009 | <a href="http://wphacks.com">WordPress Hacks</a> | <a href="http://wpnexus.com">WordPress Directory</a> | <a href="http://wpforums.com/">WordPress Forums</a> | <a href="http://wpebook.com/">WordPress eBook</a></p>

<p><small>Enjoy writing about WordPress?  Get your blog more exposure by joining the <a href="http://wphacks.com/write/">WordPress Hacks writing team</a>!</small></p>]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/collection-of-wordpress-comment-hacks/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
