<?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>Nicolas Kuttler &#187; theme</title>
	<atom:link href="http://www.nkuttler.de/tag/theme/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nkuttler.de</link>
	<description>WordPress Services, IT Services</description>
	<lastBuildDate>Wed, 28 Jul 2010 23:49:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to add support for navigation menus to your WordPress theme</title>
		<link>http://www.nkuttler.de/2010/06/08/wp_nav_menu-wordpress-3-0/</link>
		<comments>http://www.nkuttler.de/2010/06/08/wp_nav_menu-wordpress-3-0/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 15:00:50 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress theme]]></category>
		<category><![CDATA[wp_nav_menu]]></category>

		<guid isPermaLink="false">http://www.nkuttler.de/?p=1613</guid>
		<description><![CDATA[The new navigation menus system in WordPress 3.0 looks promising, but in my opinion it&#8217;s not very usable yet. Anyway, here&#8217;s one way to add navigation menus to your theme while maintaining backward compatibility: In your theme&#8217;s functions.php add something like the following code: 1 2 3 4 5 6 7 8 9 10 11 [...]]]></description>
			<content:encoded><![CDATA[<p>The new <a href="http://codex.wordpress.org/Appearance_Menus_SubPanel">navigation menus</a> system in WordPress 3.0 looks promising, but in my opinion it&#8217;s not very usable yet. Anyway, here&#8217;s one way to add navigation menus to your theme while maintaining backward compatibility:</p>
<p>In your theme&#8217;s <code>functions.php</code> add something like the following code:<span id="more-1613"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> mytheme_addmenus<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	register_nav_menus<span style="color: #009900;">&#40;</span>
		<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'main_nav'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'The Main Menu'</span><span style="color: #339933;">,</span>
		<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mytheme_addmenus'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> mytheme_nav<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_nav_menu'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
        wp_nav_menu<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'menu=main_nav&amp;container_class=pagemenu&amp;fallback_cb=mytheme_nav_fallback'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">else</span>
        mytheme_nav_fallback<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> mytheme_nav_fallback<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    wp_page_menu<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'show_home=Start&amp;menu_class=pagemenu'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>In line 1 we add support for the navigation menus. The <code>mytheme_nav()</code> function is what you will use in the theme to display the menu. Inside that function we check if <code>wp_nav_menu()</code> exists, that means if we&#8217;re running WordPress 3.0 (or later). If not we&#8217;ll use the fallback function <code>mytheme_nav_fallback()</code>.</p>
<p>Notice that the fallback also gets called if no navigation menus have been created in the admin area. That&#8217;s what the <code>fallback_cb</code> parameter on line 4 does.</p>
<p>To keep the HTM markup and the CSS consistent you&#8217;ll have to use the <code>container_class</code> parameter on <code>wp_nav_menu</code> but the <code>menu_class</code> parameter for <code>wp_page_menu</code>.</p>
<p>In your template use the following code to use your new custom function:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> mytheme_nav<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h3>Resources</h3>
<ul>
<li><a href="http://codex.wordpress.org/Function_Reference/wp_nav_menu">wp_nav_menu() reference</a></li>
<li><a href="http://codex.wordpress.org/Template_Tags/wp_page_menu">wp_page_menu() reference</a></li>
<li><a href="http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus">Informative article on nav menus by Justin Tadlock</a></li>
</ul>
<a name="wptoc_0_0_0"></a><h2>Ramblings</h2>
<p>What&#8217;s good about the new menu system:</p>
<ul>
<li>Total control over what appears in the menu</li>
<li>You can add posts, pages, categories and tags in the menu</li>
<li>Very nice drag and drop interface</li>
</ul>
<p>What&#8217;s bad:</p>
<ul>
<li>You will have to teach your users how to use the system properly.</li>
<li>If you create new pages they won&#8217;t be added to your existing menu (except for top level pages).</li>
<li>You can not control your page menus through the navigation menus interface. I think it is&#8230; very very odd that WordPress doesn&#8217;t have a simple drag-and-drop interface to arrange pages.</li>
<li>The previous point means that the new menu system is useless unless you update your theme.</li>
<li>The <code>wp_nav_menu()</code> call is inconsistent with the existing <code>wp_page_menu()</code> function.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2010/06/08/wp_nav_menu-wordpress-3-0/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Nesting WordPress loops</title>
		<link>http://www.nkuttler.de/2010/05/30/wordpress-loop-inside-a-loop/</link>
		<comments>http://www.nkuttler.de/2010/05/30/wordpress-loop-inside-a-loop/#comments</comments>
		<pubDate>Sun, 30 May 2010 13:01:47 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[shortcode]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress loop]]></category>
		<category><![CDATA[WordPress theme]]></category>

		<guid isPermaLink="false">http://www.nkuttler.de/?p=1559</guid>
		<description><![CDATA[Sometimes it&#8217;s useful to put a WordPress loop inside another loop. To do this you&#8217;ll have to create a new WP_Query object, as in this example: $my_query = new WP_Query&#40; &#34;cat=3&#34; &#41;; if &#40; $my_query-&#62;have_posts&#40;&#41; &#41; &#123; while &#40; $my_query-&#62;have_posts&#40;&#41; &#41; &#123; $my_query-&#62;the_post&#40;&#41;; the_content&#40;&#41;; &#125; &#125; $GLOBALS&#91;'post'&#93; = $GLOBALS&#91;'wp_query'&#93;-&#62;post; Restoring $post is necessary because $post->comment_status [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes it&#8217;s useful to put a WordPress loop inside another loop. To do this you&#8217;ll have to create a new <code>WP_Query</code> object, as in this example:<span id="more-1559"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">   <span style="color: #000088;">$my_query</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;cat=3&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
           <span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
           the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span>  <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wp_query'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #339933;">;</span></pre></div></div>

<p>Restoring <code>$post</code> is necessary because <code>$post->comment_status</code> of the post in the outer loop can be wrong after running the inner loop. That was the only problem I found, by I prefer to restore <code>$post completely</code> just to be sure. WordPress 3.0 has a function <code>wp_reset_postdata()</code> that you can use to restore <code>$post</code>.</p>
<p>I use this technique to show an &#8220;excerpt cloud&#8221; in a post using a <a href="http://codex.wordpress.org/Shortcode_API">shortcode</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2010/05/30/wordpress-loop-inside-a-loop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a valid WordPress theme</title>
		<link>http://www.nkuttler.de/2009/09/12/creating-a-valid-wordpress-theme/</link>
		<comments>http://www.nkuttler.de/2009/09/12/creating-a-valid-wordpress-theme/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 10:02:07 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[Webdesign]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress theme]]></category>

		<guid isPermaLink="false">http://www.nkuttler.de//?p=484</guid>
		<description><![CDATA[Recently, I&#8217;ve been checking out some of the blogs that link back to me because they use one of my plugins. And it seems like a lot of them are using buggy, incorrect templates. It looks like many WordPress theme developers don&#8217;t read the theme development checklist. Another fine document that some developers seem to [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I&#8217;ve been checking out some of the blogs that <a href="http://siteexplorer.search.yahoo.com/">link back to me</a> because they use one of my plugins. And it seems like a lot of them are using buggy, incorrect templates. It looks like many WordPress theme developers don&#8217;t read the <a href="http://codex.wordpress.org/Theme_Development_Checklist">theme development checklist</a>.<span id="more-484"></span></p>
<p>Another fine document that some developers seem to ignore is the list of <a href="http://codex.wordpress.org/Theme_Development#Plugin_API_Hooks">plugin API hooks</a>. Please, read that section, and <strong>include these hooks</strong> in your template! Some plugins <b>need</b> that API hook to work at all. My surprisingly popular <a href="http://www.nkuttler.de/nksnow/">snowstorm plugin</a> for example certainly does.</p>
<p>While you&#8217;re at it, think about how you want to style, for example, the <tt>wp_footer()</tt> call. When I visit pages that give me a backlink through that call, sometimes the backlink is displayed in very odd places and with weird colors.</p>
<p>Finally, although it has already been said on the pages I linked to, <strong> get the <a href="http://codex.wordpress.org/Theme_Development_Checklist#.22Theme_Unit_Tests.22">theme unit tests</a></strong> and use them! It&#8217;s quite embarassing for a designer to release buggy WordPress templates.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2009/09/12/creating-a-valid-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPress 2.7 and the comment pager</title>
		<link>http://www.nkuttler.de/2008/11/04/comment-paging-in-wordpress-27/</link>
		<comments>http://www.nkuttler.de/2008/11/04/comment-paging-in-wordpress-27/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 23:41:28 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[Webdesign]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress theme]]></category>

		<guid isPermaLink="false">http://www.nkuttler.de//?p=397</guid>
		<description><![CDATA[Comment paging is a great new feature in WordPress 2.7. However, how do you not display the pager when there are no previous or next comments? After digging through the code for quite a while and chatting with some people here&#8217;s a solution: &#60;?php if &#40; have_comments&#40;&#41; &#41; &#123; ?&#62; &#60;ol class=&#34;commentlist&#34;&#62; &#60;?php wp_list_comments&#40;&#41;; if [...]]]></description>
			<content:encoded><![CDATA[<p>Comment paging is a great new feature in WordPress 2.7. However, how do you not display the pager when there are no previous or next comments? After digging through the code for quite a while and chatting with some people here&#8217;s a solution:<span id="more-397"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> have_comments<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;ol class=&quot;commentlist&quot;&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span>
    wp_list_comments<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'page_comments'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>
        get_query_var<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cpage'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">||</span>
        get_query_var<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cpage'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> get_comment_pages_count<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">?&gt;</span> &lt;!-- pager HTML --&gt; <span style="color: #000000; font-weight: bold;">&lt;?php</span>
            next_comments_link<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">?&gt;</span> &lt;!-- pager HTML --&gt; <span style="color: #000000; font-weight: bold;">&lt;?php</span>
            previous_comments_link<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
            <span style="color: #000000; font-weight: bold;">?&gt;</span> &lt;!-- pager HTML --&gt; <span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;/ol&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>If you want to get started with 2.7 theme migration have a look at <a href="http://ottodestruct.com/blog/2008/09/29/wordpress-27-comments-enhancements/">Otto&#8217;s</a> or <a href="http://sivel.net/2008/10/wp-27-comment-separation/">Matt&#8217;s</a> posts on the new comment system and ping/comment separation.</p>
<p><b>Update:</b> No, <tt>get_previous_posts_page_link()</tt> is incorrect and <tt>get_previous_comments_link()</tt> doesn&#8217;t exist (yet).</p>
<p><b>Update 2:</b> Thanks to Viper007Bond for pointing me in the right direction.</p>
<p><b>Update 3:</b> <a href="http://trac.wordpress.org/ticket/8058">trac ticket</a></p>
<p><b>Update 4:</b> Additional conditional to not show the pager at all if paging isn&#8217;t enabled.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2008/11/04/comment-paging-in-wordpress-27/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
