<?xml version="1.0" encoding="UTF-8"?><!-- generator="bbPress" -->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>ThemeShaper Forums Topic: Conditional tag for nav_below</title>
<link>http://themeshaper.com/forums/</link>
<description>Help In Shaping WordPress Themes</description>
<language>en</language>
<pubDate>Wed, 22 May 2013 01:09:57 +0000</pubDate>

<item>
<title>middlesister on "Conditional tag for nav_below"</title>
<link>http://themeshaper.com/forums/topic/conditional-tag-for-nav_below#post-20246</link>
<pubDate>Sun, 03 Apr 2011 09:28:51 +0000</pubDate>
<dc:creator>middlesister</dc:creator>
<guid isPermaLink="false">20246@http://themeshaper.com/forums/</guid>
<description>&#60;p&#62;Ah sorry, I just reread your post a bit more carefully. is_category() is only true on category archive pages and you were on a single post page template you said? &#60;/p&#62;
&#60;p&#62;Maybe try is_page_template('name-of-template'), or is_page('page-ID') instead.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;function childtheme_filter_nav_links($args) {
	if (is_page_template(&#38;#39;my-template.php&#38;#39;)) {
		$args[&#38;#39;in_same_cat&#38;#39;] = true;
	}
	return $args;
}
add_filter(&#38;#39;thematic_previous_post_link_args&#38;#39;,&#38;#39;childtheme_filter_nav_links&#38;#39;);
add_filter(&#38;#39;thematic_next_post_link_args&#38;#39;,&#38;#39;childtheme_filter_nav_links&#38;#39;);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Yes you can definately use conditionals in the code you posted. The trick is just finding the right one. :)&#60;br /&#62;
I still think though that the reason that the previous and next post links are showing all posts instead of just one category is that you are calling thematic_previous_post_link() which by default refers to all the posts. We need to tell the previous_post_link function to only link to posts in the same category. Either filter the arguments to thematic_previous_post_link or use the wordpress functions directly in you own nav_below:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;// ETC CODE
function mgd_thematic_nav_below() {
if (is_page_template(&#38;#39;my-template.php&#38;#39;)) { ?&#38;gt;
	&#38;lt;h3 class=&#38;quot;additional-posts&#38;quot;&#38;gt;Additional Posts&#38;lt;/h3&#38;gt;
	&#38;lt;div id=&#38;quot;nav-below&#38;quot; class=&#38;quot;navigation&#38;quot;&#38;gt;
	&#38;lt;div class=&#38;quot;nav-previous&#38;quot;&#38;gt;&#38;lt;span class=&#38;quot;nav-direction&#38;quot;&#38;gt;Previous&#38;lt;/span&#38;gt;&#38;lt;?php previous_post_link(&#38;#39;%link&#38;#39;, &#38;#39;Previous in category&#38;#39;, true); ?&#38;gt;&#38;lt;/div&#38;gt;
	&#38;lt;div class=&#38;quot;nav-next&#38;quot;&#38;gt;&#38;lt;span class=&#38;quot;nav-direction&#38;quot;&#38;gt;Next&#38;lt;/span&#38;gt;&#38;lt;?php next_post_link(&#38;#39;%link&#38;#39;, &#38;#39;Next post in category&#38;#39;, true); ?&#38;gt;&#38;lt;/div&#38;gt;
	&#38;lt;/div&#38;gt;
	&#38;lt;?php
}
// ETC CODE&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Check out the wordpress codex at &#60;a href=&#34;http://codex.wordpress.org/Function_Reference/previous_post_link&#34; rel=&#34;nofollow&#34;&#62;http://codex.wordpress.org/Function_Reference/previous_post_link&#60;/a&#62; on how to format the link.
&#60;/p&#62;</description>
</item>
<item>
<title>AnotherAndrew on "Conditional tag for nav_below"</title>
<link>http://themeshaper.com/forums/topic/conditional-tag-for-nav_below#post-20242</link>
<pubDate>Sun, 03 Apr 2011 01:58:14 +0000</pubDate>
<dc:creator>AnotherAndrew</dc:creator>
<guid isPermaLink="false">20242@http://themeshaper.com/forums/</guid>
<description>&#60;p&#62;middlesister,&#60;/p&#62;
&#60;p&#62;Thanks for the suggestion but that didn't work. &#60;/p&#62;
&#60;p&#62;Is there not a way to use conditionals in the code I have above?&#60;/p&#62;
&#60;p&#62;It seems like this would work, but it doesn't:&#60;/p&#62;
&#60;p&#62;// ETC CODE&#60;br /&#62;
function mgd_thematic_nav_below() {&#60;br /&#62;
		if (is_single() &#124;&#124; is_category('10')) { ?&#38;gt;&#60;br /&#62;
			&#38;lt;h3 class=&#34;additional-posts&#34;&#38;gt;Additional Posts&#38;lt;/h3&#38;gt;&#60;br /&#62;
			&#38;lt;div id=&#34;nav-below&#34; class=&#34;navigation&#34;&#38;gt;&#60;br /&#62;
				&#38;lt;div class=&#34;nav-previous&#34;&#38;gt;&#38;lt;span class=&#34;nav-direction&#34;&#38;gt;Previous&#38;lt;/span&#38;gt;&#38;lt;?php thematic_previous_post_link() ?&#38;gt;&#38;lt;/div&#38;gt;&#60;br /&#62;
				&#38;lt;div class=&#34;nav-next&#34;&#38;gt;&#38;lt;span class=&#34;nav-direction&#34;&#38;gt;Next&#38;lt;/span&#38;gt;&#38;lt;?php thematic_next_post_link() ?&#38;gt;&#38;lt;/div&#38;gt;&#60;br /&#62;
			&#38;lt;/div&#38;gt;&#60;br /&#62;
// ETC CODE
&#60;/p&#62;</description>
</item>
<item>
<title>middlesister on "Conditional tag for nav_below"</title>
<link>http://themeshaper.com/forums/topic/conditional-tag-for-nav_below#post-20235</link>
<pubDate>Sat, 02 Apr 2011 08:04:26 +0000</pubDate>
<dc:creator>middlesister</dc:creator>
<guid isPermaLink="false">20235@http://themeshaper.com/forums/</guid>
<description>&#60;p&#62;I don't think it is necessary to remove and replace nav_below. You can use conditionals to filter the arguments passed to previous_post_link and next_post_link instead.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;function childtheme_filter_nav_links($args) {
	if (is_category(&#38;#39;10&#38;#39;)) {
		$args[&#38;#39;in_same_cat&#38;#39;] = true;
	}
	return $args;
}
add_filter(&#38;#39;thematic_previous_post_link_args&#38;#39;,&#38;#39;childtheme_filter_nav_links&#38;#39;);
add_filter(&#38;#39;thematic_next_post_link_args&#38;#39;,&#38;#39;childtheme_filter_nav_links&#38;#39;);&#60;/code&#62;&#60;/pre&#62;</description>
</item>
<item>
<title>AnotherAndrew on "Conditional tag for nav_below"</title>
<link>http://themeshaper.com/forums/topic/conditional-tag-for-nav_below#post-20224</link>
<pubDate>Sat, 02 Apr 2011 00:54:09 +0000</pubDate>
<dc:creator>AnotherAndrew</dc:creator>
<guid isPermaLink="false">20224@http://themeshaper.com/forums/</guid>
<description>&#60;p&#62;I am trying to have posts from just one category to show in the additional posts navigation in nav_below. &#60;/p&#62;
&#60;p&#62;However, I am getting all posts to show in every category and they are displaying in order of the published date.&#60;/p&#62;
&#60;p&#62;I am using a single post template for category 10, if that matters.&#60;/p&#62;
&#60;p&#62;This is my code in functions.php:&#60;/p&#62;
&#60;p&#62;// MGD nav_below&#60;br /&#62;
// Remove the default nav_below&#60;br /&#62;
function remove_thematic_actions() {&#60;br /&#62;
    remove_action('thematic_navigation_below', 'thematic_nav_below', 2);&#60;br /&#62;
}&#60;br /&#62;
// Call 'nav_below' (above) during WP initialization&#60;br /&#62;
add_action('init','remove_thematic_actions');&#60;/p&#62;
&#60;p&#62;function mgd_thematic_nav_below() {&#60;br /&#62;
		if (is_category('10')) { ?&#38;gt;&#60;br /&#62;
			&#38;lt;h3 class=&#34;additional-posts&#34;&#38;gt;Additional Posts&#38;lt;/h3&#38;gt;&#60;br /&#62;
			&#38;lt;div id=&#34;nav-below&#34; class=&#34;navigation&#34;&#38;gt;&#60;br /&#62;
				&#38;lt;div class=&#34;nav-previous&#34;&#38;gt;&#38;lt;span class=&#34;nav-direction&#34;&#38;gt;Previous&#38;lt;/span&#38;gt;&#38;lt;?php thematic_previous_post_link() ?&#38;gt;&#38;lt;/div&#38;gt;&#60;br /&#62;
				&#38;lt;div class=&#34;nav-next&#34;&#38;gt;&#38;lt;span class=&#34;nav-direction&#34;&#38;gt;Next&#38;lt;/span&#38;gt;&#38;lt;?php thematic_next_post_link() ?&#38;gt;&#38;lt;/div&#38;gt;&#60;br /&#62;
			&#38;lt;/div&#38;gt;&#60;/p&#62;
&#60;p&#62;&#38;lt;?php&#60;br /&#62;
		} else { ?&#38;gt;&#60;br /&#62;
			&#38;lt;h3 class=&#34;additional-posts&#34;&#38;gt;Navigate Additional Posts&#38;lt;/h3&#38;gt;&#60;br /&#62;
			&#38;lt;div id=&#34;nav-below&#34; class=&#34;navigation&#34;&#38;gt;&#60;br /&#62;
                &#38;lt;?php if(function_exists('wp_pagenavi')) { ?&#38;gt;&#60;br /&#62;
                &#38;lt;?php wp_pagenavi(); ?&#38;gt;&#60;br /&#62;
                &#38;lt;?php } else { ?&#38;gt;&#60;br /&#62;
				&#38;lt;div class=&#34;nav-previous uppercase&#34;&#38;gt;&#38;lt;?php next_posts_link(__('&#38;lt;span class=&#34;meta-nav&#34;&#38;gt;&#38;laquo;&#38;lt;/span&#38;gt; Previous', 'thematic')) ?&#38;gt;&#38;lt;/div&#38;gt;&#60;br /&#62;
				&#38;lt;div class=&#34;nav-next uppercase&#34;&#38;gt;&#38;lt;?php previous_posts_link(__('Next &#38;lt;span class=&#34;meta-nav&#34;&#38;gt;&#38;raquo;&#38;lt;/span&#38;gt;', 'thematic')) ?&#38;gt;&#38;lt;/div&#38;gt;&#60;br /&#62;
				&#38;lt;?php } ?&#38;gt;&#60;br /&#62;
			&#38;lt;/div&#38;gt;	&#60;/p&#62;
&#60;p&#62;&#38;lt;?php&#60;br /&#62;
		}&#60;br /&#62;
} // end nav_below&#60;/p&#62;
&#60;p&#62;Anyone know what I am doing wrong?
&#60;/p&#62;</description>
</item>

</channel>
</rss>
