<?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; WordPress Loop</title>
	<atom:link href="http://wphacks.com/tag/wordpress-loop/feed/" rel="self" type="application/rss+xml" />
	<link>http://wphacks.com</link>
	<description>WordPress Themes, Plugins, Hacks, Tutorials, and more!</description>
	<lastBuildDate>Fri, 25 May 2012 20:07:36 +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: Create a Multi-Language Blog</title>
		<link>http://wphacks.com/how-to-create-a-multi-language-blog/</link>
		<comments>http://wphacks.com/how-to-create-a-multi-language-blog/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 08:00:40 +0000</pubDate>
		<dc:creator>Jean-Baptiste Jung</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[WordPress Code]]></category>
		<category><![CDATA[WordPress Languages]]></category>
		<category><![CDATA[WordPress Loop]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=793</guid>
		<description><![CDATA[Using WordPress plugins to automatically translate blog content This is the easiest solution. A few WordPress plugins allows you to put some clickable flags in your sidebar, that will automatically translate your content to another language using, for example, Google Translate. This is a great solution if you&#8217;re looking for a way to make your [...]]]></description>
			<content:encoded><![CDATA[<h2>Using WordPress plugins to automatically translate blog content</h2>
<p>This is the easiest solution. A few WordPress plugins allows you to put some clickable flags in your sidebar, that will automatically translate your content to another language using, for example, Google Translate.<br />
This is a great solution if you&#8217;re looking for a way to make your content available for people that doesn&#8217;t speak your language, but you guessed it, the automatic translation isn&#8217;t as good as a human translated text.</p>
<p>Anyways, if you&#8217;re interested in theses plugins, here&#8217;s a small list. I didn&#8217;t tried them all myself, though.</p>
<ul>
<li><a href="http://www.nothing2hide.net/wp-plugins/wordpress-global-translator-plugin/">Global Translator Plugin</a></li>
<li><a href="http://trevorcreech.com/blog/2007/02/17/translate-widget-20/">Translate Widget</a></li>
<li><a href="http://onemansblog.com/2007/03/25/google-translate-wordpress-plugin/">Google Translate WordPress Plugins</a></li>
</ul>
<h2>Using categories and a few hacks</h2>
<p>If you&#8217;re a perfectionist, you probably don&#8217;t really like the automatic translations provided by Google. In my opinion, if it&#8217;s okay for a personal blog, but automatic translations should be avoided on a professional blog.</p>
<p>For this hack, we will use categories. Go to your dashboard and create categories/sub-categories following the example below:</p>
<pre>English
    One category
    Two categories
Français
    Une catégorie
    Deux catégories
Deutsch
    Eine kategorie
    Zwei kategorien</pre>
<p>Of course this is just an example, you can add as many categories as you want. The thing to remember here is that we&#8217;re using top level categories for languages, each of them having sub-categories organized by topics.</p>
<p>Now, you should post at least one example post in each sub-category. Once you&#8217;re done, we can start editing our header.php template.</p>
<p>The idea is quite simple: First, we must display the available languages, and then, a menu with the sub-category related to the current language. We must also think about defining a default language, which will be English in this example.</p>
<p><strong>1 &#8211; Creating the language menu</strong><br />
Insert the following code where you want the language selection menu to appear:</p>
<pre>&lt;?php
wp_list_categories('title_li=');
$lang = 1; // Sets the default language
?&gt;</pre>
<p>As you can see, we just need the good old <em>wp_list_categories()</em> function to get our available languages.<br />
Then, we have to keep a php variable containing the id of the top level category, in order to display the navigation menu in the selected language. We must give a default value to the $lang variable. This default value will be the category id of the language you want to set as default.</p>
<p>I noticed that many people should have trouble to find the ID of a particular category. If you do, you should definitely read <a href="http://wphacks.com/how-to-finding-category-numbers-in-wordpress-25/">this post</a>.</p>
<p><strong>2 &#8211; Navigation menu</strong><br />
Now, we got a php variable containing the id of the mother category. As the top-level categories are languages, we know which language the user is using.</p>
<p>We simply have to display second-level categories.</p>
<pre>&lt;ul&gt;
&lt;?php
wp_list_categories('title_li=&amp;child_of=$lang');
?&gt;
&lt;/ul&gt;</pre>
<p><strong>3 &#8211; Retrieving category</strong><br />
Here&#8217;s a sample code you can use to automatically list posts from a category. This code get the current category (in this example, the language) and then displays the related posts.</p>
<pre>&lt;?php foreach((get_the_category()) as $category) {
      	$thecat = $category-&gt;cat_ID . ' ';
    	query_posts('child_of='.$thecat);
	if (have_posts()) : while (have_posts()) : the_post();
	   //Classic WP loop
	endwhile;endif;
?&gt;</pre>
<img src="http://wphacks.com/?ak_action=api_record_view&id=785&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/how-to-create-a-multi-language-blog/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>How To: Insert Ads Only After the First Post</title>
		<link>http://wphacks.com/how-to-insert-ads-only-after-the-first-post/</link>
		<comments>http://wphacks.com/how-to-insert-ads-only-after-the-first-post/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 08:00:03 +0000</pubDate>
		<dc:creator>Kyle Eslick</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[WordPress Banners]]></category>
		<category><![CDATA[WordPress Code]]></category>
		<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[WordPress How-To]]></category>
		<category><![CDATA[WordPress Loop]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=914</guid>
		<description><![CDATA[Have you ever tried to insert advertisements (or any bit of code really) into the WordPress post loop, then found that it will insert the banner after each post?   It really depends on what you are going for, but this usually will not be an ideal solution to placing advertisements between posts on your homepage.   If you&#8217;d like [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever tried to insert advertisements (or any bit of code really) into the WordPress post loop, then found that it will insert the banner after each post?   It really depends on what you are going for, but this usually will not be an ideal solution to placing advertisements between posts on your homepage.   If you&#8217;d like to place something only after the first post in the WordPress post loop, here is a quick hack you can do to tell WordPress to only display it after the first post.</p>
<p>Simply go to your themes homepage and look for the following code:</p>
<p><code> &lt;?php endwhile; ?&gt;</code></p>
<p>Immediately <strong>before</strong> this code, place the following code:</p>
<p><code>&lt;?php if(!$show_ads){ ?&gt;<br />
<em>Insert Code Here<br />
</em>&lt;?php $show_ads = 1; } ?&gt;</code></p>
<p>Obviously you&#8217;ll want to replace <em>Insert Code Here</em> with your code.  Told you it was easy!</p>
<img src="http://wphacks.com/?ak_action=api_record_view&id=550&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/how-to-insert-ads-only-after-the-first-post/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>WordPress Talk &#8211; May 29, 2008</title>
		<link>http://wphacks.com/wordpress-talk-may-29-2008/</link>
		<comments>http://wphacks.com/wordpress-talk-may-29-2008/#comments</comments>
		<pubDate>Thu, 29 May 2008 08:00:20 +0000</pubDate>
		<dc:creator>Kyle Eslick</dc:creator>
				<category><![CDATA[News & Notes]]></category>
		<category><![CDATA[Visual Text Editor]]></category>
		<category><![CDATA[WordPress Loop]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=584</guid>
		<description><![CDATA[It has been awhile since I&#8217;ve done a batch of WordPress Talk links, so here are a few WordPress links for you to enjoy: How to Avoid Duplicate Posts in the WordPress Loop &#8211; This post by Weblog Tools Collection explains how to avoid duplicate posts in both a single WordPress loop and a double [...]]]></description>
			<content:encoded><![CDATA[<p>It has been awhile since I&#8217;ve done a batch of WordPress Talk links, so here are a few WordPress links for you to enjoy:</p>
<ul>
<li><a href="http://weblogtoolscollection.com/archives/2008/05/17/how-to-avoid-duplicate-posts/">How to Avoid Duplicate Posts in the WordPress Loop</a> &#8211; This post by Weblog Tools Collection explains how to avoid duplicate posts in both a single WordPress loop and a double WordPress loop.</li>
<li><a href="http://www.themelab.com/2008/05/17/how-to-get-rid-of-the-wordpress-visual-editor/">How to Get Rid of the WordPress Visual Text Editor</a> &#8211; I know a lot of people do not like using the visual text editor when writing posts.   If that sounds like you, Leland does a great job of providing the steps you need to take to remove yours.</li>
<li><a href="http://justintadlock.com/archives/2008/05/27/get-the-image-wordpress-plugin">Get the Image WordPress Plugin</a> &#8211; Justin Tadlock has released his newest plugin, which was designed to help people with images that use Magazine WordPress themes.</li>
</ul>
<img src="http://wphacks.com/?ak_action=api_record_view&id=288&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/wordpress-talk-may-29-2008/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How To: Display Adsense On Your First Post Within The Loop</title>
		<link>http://wphacks.com/how-to-display-adsense-on-your-first-post-within-the-loop/</link>
		<comments>http://wphacks.com/how-to-display-adsense-on-your-first-post-within-the-loop/#comments</comments>
		<pubDate>Sun, 11 May 2008 10:00:09 +0000</pubDate>
		<dc:creator>Leland</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[WordPress Code]]></category>
		<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[WordPress How-To]]></category>
		<category><![CDATA[WordPress Loop]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=550</guid>
		<description><![CDATA[This guest post was written by Leland of Theme Lab, where he has released over 50 WordPress themes. In addition to themes, Theme Lab also provides some WordPress guides. If you have WordPress knowledge and are interested in writing a post for Hack WordPress, please contact us. In this guide you&#8217;ll learn how to display [...]]]></description>
			<content:encoded><![CDATA[<p><em>This guest post was written by Leland of <a href="http://www.themelab.com/">Theme Lab</a>, where he has released over 50 WordPress themes. In addition to themes, Theme Lab also provides some WordPress guides. If you have 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>In this guide you&#8217;ll learn how to display Adsense on just your first post within the Loop. Sure, there may be plugins that will do this for you. This guide, however, will use code examples to accomplish the same thing by editing your WordPress theme.</p>
<p>The first step is to open up your index.php file in your theme editor. Find the following line:</p>
<p><code>&lt;?php if(have_posts()) : ?&gt;</code></p>
<p>Just above that, insert the following like this:</p>
<p><code>&lt;?php $i = 1; ?&gt;<br />
&lt;?php if(have_posts()) : ?&gt;</code></p>
<p>Now, scroll down a bit until you find this line:</p>
<p><code>&lt;?php endwhile; ?&gt;</code></p>
<p>Insert the following above it, like so:</p>
<p><code>&lt;?php $i++; ?&gt;<br />
&lt;?php endwhile; ?&gt;</code></p>
<p>The final step is to insert your Adsense code. Locate where exactly you&#8217;d like it within the Loop, and place it between a conditional tag like this:</p>
<p><code>&lt;?php if ($i == 1) { ?&gt; [YOUR ADSENSE CODE HERE] &lt;?php } ?&gt;</code></p>
<p>And that&#8217;s all you have to do. You can be creative with this code as well. You could add a certain css style class to the top post in your Loop. It doesn&#8217;t even have to be the first either, as you can just change the number in $i == 1 to whatever you want. This same method can be used in other archive templates such as archive.php.</p>
<p>You can <a title="Displaying Adsense and other ads with WordPress" href="http://www.themelab.com/2008/03/13/displaying-adsense-and-other-ads-with-wordpress/">display ads with WordPress</a> in other ways as well, including plugins such as <a title="WhyDoWork Adsense Plugin" href="http://www.whydowork.com/blog/whydowork-adsense-plugin/">WhyDoWork Adsense Plugin</a> (formerly <a href="http://wphacks.com/insert-adsense-into-posts-with-shylock-adsense/">Shylock Adsense</a>).</p>
<img src="http://wphacks.com/?ak_action=api_record_view&id=264&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/how-to-display-adsense-on-your-first-post-within-the-loop/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Ultimate Guide to the WordPress Loop</title>
		<link>http://wphacks.com/ultimate-guide-wordpress-loop-tutorial/</link>
		<comments>http://wphacks.com/ultimate-guide-wordpress-loop-tutorial/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 14:44:18 +0000</pubDate>
		<dc:creator>Kyle Eslick</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[WordPress Code]]></category>
		<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[WordPress Loop]]></category>
		<category><![CDATA[WordPress Tutorial]]></category>

		<guid isPermaLink="false">http://wphacks.com/?p=471</guid>
		<description><![CDATA[One of my favorite parts about using WordPress for my blogs is getting to work with PHP code, which I find to be much easier to write/hack.   For those that are shy around code, it really isn&#8217;t that difficult to get ahold of the basics of PHP, so WordPress is the right place for you.  [...]]]></description>
			<content:encoded><![CDATA[<p>One of my favorite parts about using WordPress for my blogs is getting to work with PHP code, which I find to be much easier to write/hack.   For those that are shy around code, it really isn&#8217;t that difficult to get ahold of the basics of PHP, so WordPress is the right place for you. </p>
<p>One great area to start is learning how the WordPress loop works.  This is a basic function of blogging used to display the most recent X number of posts on your blog&#8217;s homepage (for traditional blogs).   Rather than go into to much detail here, I&#8217;d like to point you towards a new post by Themelab which is designed to be the <a href="http://www.themelab.com/2008/04/04/the-ultimate-guide-to-the-wordpress-loop/">Utlimate Guide to the WordPress loop</a>. </p>
<p>This post definitely lives up to its name and goes beyond just showing you how to do something.  It actually explains how and why it works, and includes screenshots with many of the examples.   If you have any interest in learning about the WordPress loop you may want to read through this post and/or bookmark it for future reference. </p>
<img src="http://wphacks.com/?ak_action=api_record_view&id=220&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://wphacks.com/ultimate-guide-wordpress-loop-tutorial/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

