<?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>Banhawi &#187; Tutorials</title>
	<atom:link href="http://banhawi.com/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://banhawi.com</link>
	<description>Web Design and Development News and Tutorials</description>
	<lastBuildDate>Thu, 29 Jul 2010 00:50:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Support WP3.0 Custom Menus</title>
		<link>http://banhawi.com/2010/07/support-wp3-0-custom-menus/</link>
		<comments>http://banhawi.com/2010/07/support-wp3-0-custom-menus/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 00:42:24 +0000</pubDate>
		<dc:creator>Banhawi</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[custom menus]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[wordpress 3]]></category>

		<guid isPermaLink="false">http://banhawi.com/?p=193</guid>
		<description><![CDATA[
The new wordpress 3.0 custom menus feature is one of the best newly added features to wordpress that gives you more control on your menus every where on your web site .
Wordpress new custom menus works in simple two steps .

First : Register the menu
register your menus in your theme&#8217;s functions.php file
register_nav_menus( array( $location =&#62; [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-thumbnail wp-image-196 alignright" title="wordpress 3.0 custom menus" src="http://banhawi.com/wp-content/uploads/2010/07/custom-menu-150x150.png" alt="wordpress 3.0 custom menus" width="150" height="150" /><br />
The new wordpress 3.0 custom menus feature is one of the best newly added features to wordpress that gives you more control on your menus every where on your web site .<br />
Wordpress new custom menus works in simple two steps .</p>
<p><span id="more-193"></span></p>
<h3>First : Register the menu</h3>
<p>register your menus in your theme&#8217;s functions.php file</p>
<pre class="brush: php;">register_nav_menus( array( $location =&gt; $description ) ); </pre>
<p><strong>Real Example</strong></p>
<pre class="brush: php;">
if ( function_exists( 'register_nav_menu' ) ) {
register_nav_menu( 'topnav', 'Top Navigation' );
}
</pre>
<p>you can register as many custom menus as you want .</p>
<h3>Second : Place the menu</h3>
<p>Now it&#8217;s time to place your menus where you want it to be showed on your theme</p>
<pre class="brush: php;">
&lt;?php wp_nav_menu(); ?&gt;
</pre>
<p>That&#8217;s it , now just play with your wordpress menu designer and have fun <img src='http://banhawi.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> <br/><br />
<strong>Functions Used : </strong><a href="http://codex.wordpress.org/Function_Reference/register_nav_menu" target="_blank">register_nav_menus</a> &amp;  <a href="http://codex.wordpress.org/Function_Reference/wp_nav_menu" target="_blank">wp_nav_menu</a></p>
]]></content:encoded>
			<wfw:commentRss>http://banhawi.com/2010/07/support-wp3-0-custom-menus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Custom Function] Get Category Link by Name</title>
		<link>http://banhawi.com/2010/02/custom-function-get-category-link-by-name/</link>
		<comments>http://banhawi.com/2010/02/custom-function-get-category-link-by-name/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 00:30:34 +0000</pubDate>
		<dc:creator>Banhawi</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[custom wordpress function]]></category>
		<category><![CDATA[get_cat_ID]]></category>
		<category><![CDATA[get_category_link]]></category>
		<category><![CDATA[get_category_link_byname]]></category>
		<category><![CDATA[wordpress function]]></category>
		<category><![CDATA[wordpress function reference]]></category>
		<category><![CDATA[wordpress tutorial]]></category>

		<guid isPermaLink="false">http://banhawi.com/?p=180</guid>
		<description><![CDATA[I was working on a theme and i faced that problem , i wanted to get dynamically the category link using category names and there&#8217;s no function in wordpress to do that , so i&#8217;ve wrote a simple function that does what i need .
I&#8217;ve used get_cat_ID function to get category id using name , [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on a theme and i faced that problem , i wanted to get dynamically the category link using category names and there&#8217;s no function in wordpress to do that , so i&#8217;ve wrote a simple function that does what i need .<br />
I&#8217;ve used get_cat_ID function to get category id using name , then get_category_link function to get category link using category id , very simple .<br />
<span id="more-180"></span></p>
<pre class="brush: php;">
function get_category_link_byname($name) {
	$id = get_cat_ID($name);
	$link = get_category_link( $id );
	echo $link;
}
</pre>
<p>use this function as follows ,</p>
<pre class="brush: php;">
&lt;?php function get_category_link_byname('categoryname'); ?&gt;
</pre>
<p>and that&#8217;s it , hope you find it useful .</p>
]]></content:encoded>
			<wfw:commentRss>http://banhawi.com/2010/02/custom-function-get-category-link-by-name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wordpress Conditional Tags In Action (Different Sidebars)</title>
		<link>http://banhawi.com/2009/09/wordpress-conditional-tags-in-action-different-sidebars/</link>
		<comments>http://banhawi.com/2009/09/wordpress-conditional-tags-in-action-different-sidebars/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 04:00:35 +0000</pubDate>
		<dc:creator>Banhawi</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Wordpress Conditional Tags]]></category>

		<guid isPermaLink="false">http://banhawi.com/?p=133</guid>
		<description><![CDATA[Wordpress can be used to create any type of site that&#8217;s because of it&#8217;s powerful functions  which give developers the freedom to play and create , this tutorial is about a simple yet great for CMS sites tip which is creating different sidebars .

Problem #1
When developing sites using wordpress you may need to create different [...]]]></description>
			<content:encoded><![CDATA[<p>Wordpress can be used to create any type of site that&#8217;s because of it&#8217;s powerful functions  which give developers the freedom to play and create , this tutorial is about a simple yet great for CMS sites tip which is creating different sidebars .<br />
<span id="more-133"></span></p>
<h3>Problem #1</h3>
<p>When developing sites using wordpress you may need to create different sidebars maybe just different in content or in style too .</p>
<h3>Solution :</h3>
<p>We will create two sidebars one for home page , one for pages and one for blog<em> (categories , posts , archives &#8230; etc)</em> .</p>
<pre class="brush: php;">
&lt;?php if ( is_front_page() ) {?&gt;
	&lt;div id=&quot;home_sidebar&quot;&gt;
	...sidebar content.....
	&lt;/div&gt;
&lt;?php } /* end home_sidebar */  ?&gt;

&lt;?php if ( is_page() &amp;&amp; !is_front_page() ) {?&gt;
	&lt;div id=&quot;pages_sidebar&quot;&gt;
	...sidebar content.....
	&lt;/div&gt;
&lt;?php } /* end pages_sidebar */ ?&gt;

&lt;?php else {?&gt;
	&lt;div id=&quot;blog_sidebar&quot;&gt;
	...sidebar content.....
	&lt;/div&gt;
&lt;?php } /* end blog_sidebar */ ?&gt;
</pre>
<p>the code above explains itself , we simply created our three sidebars #home_sidebar , #pages_sidebar , #blog_sidebar which will contain different content , we used Wordpress Conditional Tags (  is_front_page() , is_page() ) .</p>
<p><strong>Line 1 : </strong>used is_front_page() tag within an if statement in order to display #home_sidebar content only in the front page<br />
<em><strong>Note :</strong> there&#8217;s a big difference between is_front_page() and is_home() </em></p>
<p><strong>Line 7 : </strong>used  is_page() &#038;&#038; !is_front_page() within an if statement in order to display the #pages_sidebar within all pages and used &#038;&#038; !is_front_page() in order not to show this sidebar within the home page if you using static page as your home page </p>
<p><strong>Line 13 : </strong> If not home page or page the #blog_sidebar will be displayed </p>
<h3>Problem #2</h3>
<p>If you used a premium portfolio or business theme or looking forward developing your own , you&#8217;ll notice that those themes looks like they using two wordpress installations , as you&#8217;ll find in most of these themes Blog and Portfolio , both with different styling , sidebars and sometimes layout</p>
<h3>Solution :</h3>
<p>With the power of conditional tags it&#8217;s not a problem , we just will create two different parent categories </p>
<p>Blog<br />
 > news<br />
 > tips<br />
 > sub category<br />
Portfolio<br />
 > web<br />
 > print</p>
<pre class="brush: php;">
&lt;?php if ( is_category('Blog') &amp;&amp; in_category('Blog')  ) {?&gt;
	&lt;div id=&quot;blog_sidebar&quot;&gt;
	...sidebar content.....
	&lt;/div&gt;
&lt;?php } /* end blog_sidebar */ ?&gt;

&lt;?php if ( is_category('Portfolio') &amp;&amp; in_category('Portfolio')  ) {?&gt;
	&lt;div id=&quot;portfolio_sidebar&quot;&gt;
	...sidebar content.....
	&lt;/div&gt;
&lt;?php } /* end portfolio_sidebar */ ?&gt;
</pre>
<p><strong><br />
Line 1 :</strong> used  is_category(&#8217;Blog&#8217;) &#038;&#038; in_category(&#8217;Blog&#8217;) within if statement to display #blog_sidebar only within category Blog , it&#8217;s sub-categories and post pages within the Blog category and it&#8217;s sub-categories .</p>
<p><strong>Line 1 :</strong> used  is_category(&#8217;Portfolio&#8217;) &#038;&#038; in_category(&#8217;Portfolio&#8217;) within if statement to display #portfolio_sidebar only within category Portfolio , it&#8217;s sub-categories and post pages within the Portfolio category and it&#8217;s sub-categories .</p>
<p>&#8230; solved</p>
]]></content:encoded>
			<wfw:commentRss>http://banhawi.com/2009/09/wordpress-conditional-tags-in-action-different-sidebars/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Wordpress Conditional Tags In Action (Breadcrumbs)</title>
		<link>http://banhawi.com/2009/06/wordpress-conditional-tags-in-action-breadcrumbs/</link>
		<comments>http://banhawi.com/2009/06/wordpress-conditional-tags-in-action-breadcrumbs/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 22:03:56 +0000</pubDate>
		<dc:creator>Banhawi</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Usability]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Breadcrumbs]]></category>

		<guid isPermaLink="false">http://banhawi.com/?p=82</guid>
		<description><![CDATA[Wordpress is the most powerful blogging system ever , even you can use it to do any type of sites (E-Commerce , CMS, Galleries .. etc) i think wordpress is going forward to be a framework , all this because of the powerful functions it offers to developers .
I&#8217;m going to use some of the [...]]]></description>
			<content:encoded><![CDATA[<p>Wordpress is the most powerful blogging system ever , even you can use it to do any type of sites (E-Commerce , CMS, Galleries .. etc) i think wordpress is going forward to be a framework , all this because of the powerful functions it offers to developers .</p>
<p>I&#8217;m going to use some of the wordpress Conditional Tags plus other wordpress functions to create a Breadcrumbs Navigation for wordpress .</p>
<p>Read More about Breadcrumbs and why to use them &#8220;<a href="http://psychology.wichita.edu/surl/usabilitynews/52/breadcrumb.htm" target="_blank">Breadcrumb Navigation: Further Investigation of Usage</a>&#8221;</p>
<p style="text-align: center;"><img class="size-full wp-image-90 aligncenter" title="breadcrumbs Navigation" src="http://banhawi.com/wp-content/uploads/2009/06/breadcrumbs.jpg" alt="breadcrumbs Navigation" width="552" height="245" /></p>
<div class="demo"><a href='http://banhawi.com/wp-content/uploads/2009/06/breadcrumbs.zip'>Source</a></div>
<p><span id="more-82"></span></p>
<h3>Step One</h3>
<p>Create a new file within your theme folder and call it breadcrumbs.php or whatever you want</p>
<h3>Step Two</h3>
<p>In home page we don&#8217;t have to show the user the breadcrumbs navigation so we will do this</p>
<pre class="brush: php;">
&lt;?php
	if ( is_home() ){}
	else {
		echo &quot;&lt;div class=\&quot;breadcrumbs\&quot;&gt;&lt;ul class=\&quot;breadcrumbs\&quot;&gt; &quot;;
		echo &quot;&lt;/ul&gt;&lt;/div&gt;&quot;;
	}
?&gt;
</pre>
<p>The code above is pretty simple , we used our first Conditional Tag ( is_home() ) within an if &#8211; else statement.</p>
<p>is_home() used to check whether the current page is the homepage or not .</p>
<p>We used it here to do nothing when it&#8217;s homepage and applying a simple html codes when it&#8217;s not homepage .</p>
<h3>Step Three</h3>
<p>Let&#8217;s Add some css styles .</p>
<pre class="brush: css;">
ul.breadcrumbs {
	list-style: none;
	padding: 0;
	margin: 0;
	float: left;
}
ul.breadcrumbs li {
	float: left;
	margin: 0 5px 0 0;
	padding: 0;
}
ul.breadcrumbs li:before {
	content: &quot;\00BB \0020&quot;;
}
</pre>
<p>We simply styled the ul.breadcrumbs menu as a horizontal menu and added right angle quote before every &#8220;li&#8221; member .</p>
<h3>Step Four</h3>
<p>The blog name must be added before any thing so we&#8217;ve to add it to our code .</p>
<pre class="brush: php;">
&lt;?php
	if ( is_home() ){}
	else {
		echo &quot;&lt;div class=\&quot;breadcrumbs\&quot;&gt;&lt;ul class=\&quot;breadcrumbs\&quot;&gt; &quot;;
		echo &quot;&lt;li&gt;&lt;a href=\&quot; &quot;.get_settings('home').&quot; \&quot;&gt;&quot;;
		echo  bloginfo('name').&quot;&lt;/a&gt;&lt;/li&gt;&quot;;
		echo &quot;&lt;/ul&gt;&lt;/div&gt;&quot;;
	}
?&gt;</pre>
<p>In the code above we&#8217;ve added the blog name using the wordpress function bloginfo(&#8217;name&#8217;); within &#8220;li&#8221; tags and linked it to the blog url using the wordpress function get_settings(&#8217;home&#8217;) which retrieves the blog link .</p>
<h3>Step Five</h3>
<p><strong>Output</strong> :   » Blog Name » Category Name  »</p>
<p><strong>Another Output </strong>:   » Blog Name » Category Name  » Sub-Category Name »</p>
<p>We will start our breadcrumbs code in the Category Pages</p>
<pre class="brush: php;">
if ( is_category() ) {
	$cate = single_cat_title(&quot;&quot;,false);
	$cat = get_cat_ID($cate);
	echo &quot;&lt;li&gt;&quot;.(get_category_parents($cat, TRUE,&quot; &amp;raquo; &quot;)).&quot;&lt;/li&gt;&quot;;
}
</pre>
<p>In the code above we used is_category() &#8211; Conditional Tag , which checks if the current page is a category one or not , then the code above will only be executed within the category pages .</p>
<p>We can simply print the current category using single_cat_title(); but we won&#8217;t as we can have multi-leveled categories so we&#8217;ve to show the current category plus it&#8217;s parents if there any .</p>
<p>We can get the parents of any category using the get_category_parents(); function , and we will use it , but the problem is the output of the single_cat_title(); is the category name and to get the category parents using the get_category_parents(); function we have to pass it the category ID , so we will use get_cat_ID($cate); function to get the current category ID from the current category name .</p>
<p><em>Note :</em> single_cat_title(&#8221;",false); function&#8217;s second argument must be false as we don&#8217;t want the function to print the category name by itself we want to use the output within another function without printing it so u&#8217;ve to declare the second argument to false .</p>
<h3>Step Six</h3>
<p>Let&#8217;s apply our breadcrumbs to archives , search , 404 error pages .</p>
<p><strong>Output 1</strong>:   » Blog Name » Archives</p>
<p><strong>Output 2</strong>:   » Blog Name » Search Results</p>
<p><strong>Output 3</strong>:   » Blog Name » 404 Not Found</p>
<pre class="brush: php;">
elseif ( is_archive() &amp;&amp; !is_category() ) {
	echo &quot;&lt;li&gt;Archives&lt;/li&gt;&quot;;
}
elseif ( is_search() ) {
	echo &quot;&lt;li&gt;Search Results&lt;/li&gt;&quot;;
}
elseif ( is_404() ) {
	echo &quot;&lt;li&gt;404 Not Found&lt;/li&gt;&quot;;
}
</pre>
<p>Obviously you know what&#8217;s the function of the above code , it&#8217;s pretty easy code .</p>
<p>We first used is_archive() &#8211; Conditional Tag to check if the page is a  archive pages and printing &#8220;Archives&#8221; if it&#8217;s  an Archive page , we also used<br />
&amp;&amp; !is_category() &#8211; because category page are also archive pages and we don&#8217;t want to print Archives within the category pages so we added &amp;&amp; (AND) !(NOT) is_category()</p>
<p>Then we used is_search() &#8211; Conditional Tag to check if the page is a search page and printing &#8220;Search Results&#8221; if it&#8217;s a search page .</p>
<p>Then we used is_404() &#8211; Conditional Tag to check is the page is a 404 error page and printing &#8220;404 Not Found&#8221; if it&#8217;s a 404 error page .</p>
<h3>Step Seven</h3>
<p>Let&#8217;s apply the breadcrumbs to the single post pages</p>
<p><strong>Output</strong> :   » Blog Name » Category Name  » Post Name</p>
<pre class="brush: php;">
elseif ( is_single() ) {
	$category = get_the_category();
	$category_id = get_cat_ID($category[0]-&gt;cat_name);
	$cat_link = get_category_link( $category_id );
	echo &quot;&lt;li&gt;&lt;a href=\&quot; &quot;. $cat_link .&quot; \&quot;&gt;&quot; . $category[0]-&gt;cat_name.&quot;&lt;/a&gt;&lt;/li&gt;&quot;;
	echo &quot;&lt;li&gt;&quot;;
	echo the_title().&quot;&lt;/li&gt;&quot;;
}
</pre>
<p>In the code above we used is_single() &#8211; Conditional Tag to check if the page is a single post page and printing the category followed by the post name if it&#8217;s a single post page.</p>
<p><strong>$category = get_the_category(); </strong>To get the category .<br />
<strong>$category_id = get_cat_ID($category[0]-&gt;cat_name);</strong> To get the category ID from the category name ($category[0]-&gt;cat_name) , $category[0] that ZERO because we will only get the first category from the categories array (posts may be posted in many categories and we only need  the first) .<br />
<strong>$cat_link = get_category_link( $category_id );</strong> To get the category URL .</p>
<p>then we just print the category , followed by the post title using the_title()- wordpress function .</p>
<h3>Step Eight</h3>
<p>Let&#8217;s apply the breadcrumbs to the Pages</p>
<p><strong>Output</strong> :   » Blog Name » Page Name</p>
<p><strong>Another Output</strong> :   » Blog Name » Page Name » Sub-Page Name</p>
<pre class="brush: php;">
			elseif ( is_page() ) {

				if ($post-&gt;post_parent) {

  					$children = $post-&gt;post_title;

  					$parent = get_page($post-&gt;post_parent);

  					echo &quot;&lt;li&gt;&quot;.$parent-&gt;post_title.&quot;&lt;/li&gt;&quot;.&quot;&lt;li&gt;&quot;.$children.&quot;&lt;/li&gt;&quot;;
				}
				elseif ( $post-&gt;post_parent == 0 ) {

					echo &quot;&lt;li&gt;&quot;;

					echo the_title().&quot;&lt;/li&gt;&quot;;

				}
			}
</pre>
<p>This is the hard part , as there&#8217;s a wordpress function to retrieve page parents . So we wrote some code to retrieve the first page , this will give you the ability to show your breadcrumbs navigation in the second level pages but not in the third level pages as it&#8217;ll retrieve the second level page parent only without the first level page parent .</p>
<p>We start our code block with is_page() &#8211; Conditional Tag to check if it&#8217;s a normal page .</p>
<p>After that we write another if &#8211; else statement to check if the current page has a parent and if not we will just print the current page title .</p>
<p>If the current page has a parent :</p>
<p>We store the current page name in the $children variable  ( $children = $post-&gt;post_title; ) .<br />
Then we use the get_page(); wordpress function to get the parent page and store it in the $parent varialble $parent = get_page($post-&gt;post_parent);  .</p>
<p>Finally we print the page parent name followed by the page name as shown in line 10 .</p>
<pre class="brush: php;">
				elseif ( $post-&gt;post_parent == 0 ) {

					echo &quot;&lt;li&gt;&quot;;

					echo the_title().&quot;&lt;/li&gt;&quot;;

				}
</pre>
<p>The code above means if there&#8217;s no page parent just print the title of the page .</p>
<h2>The Complete Code </h2>
<pre class="brush: php;">
	&lt;?php
	/*
		Wordpress Breadcrumbs code by Banhawi.com

	*/

		if ( is_home() ){}

		else {

			echo &quot;&lt;div class=\&quot;breadcrumbs\&quot;&gt;&lt;ul class=\&quot;breadcrumbs\&quot;&gt; &quot;;

			echo &quot;&lt;li&gt;&lt;a href=\&quot; &quot;.get_settings('home').&quot; \&quot;&gt;&quot;;
			echo  bloginfo('name').&quot;&lt;/a&gt;&lt;/li&gt;&quot;;

			if ( is_category() ) {
				$cate = single_cat_title(&quot;&quot;,false);
				$cat = get_cat_ID($cate);
				echo &quot;&lt;li&gt;&quot;.(get_category_parents($cat, TRUE,&quot; &amp;raquo; &quot;)).&quot;&lt;/li&gt;&quot;;
			}
			elseif ( is_archive() &amp;&amp; !is_category() ) {
				echo &quot;&lt;li&gt;Archives&lt;/li&gt;&quot;;
			}
			elseif ( is_search() ) {
				echo &quot;&lt;li&gt;Search Results&lt;/li&gt;&quot;;
			}
			elseif ( is_404() ) {
				echo &quot;&lt;li&gt;404 Not Found&lt;/li&gt;&quot;;
			}
			elseif ( is_single() ) {
				$category = get_the_category();
				$category_id = get_cat_ID($category[0]-&gt;cat_name);
				$cat_link = get_category_link( $category_id );
				echo &quot;&lt;li&gt;&quot;.(get_category_parents($category, TRUE,&quot;&quot;)).&quot;&lt;/li&gt;&quot;;
				echo &quot;&lt;li&gt;&lt;a href=\&quot; &quot;. $cat_link .&quot; \&quot;&gt;&quot; . $category[0]-&gt;cat_name.&quot;&lt;/a&gt;&lt;/li&gt;&quot;;
				echo &quot;&lt;li&gt;&quot;;
				echo the_title().&quot;&lt;/li&gt;&quot;;
			}
			elseif ( is_page() ) {

				if ($post-&gt;post_parent) {

  					$children = $post-&gt;post_title;

  					$parent = get_page($post-&gt;post_parent);

  					echo &quot;&lt;li&gt;&quot;.$parent-&gt;post_title.&quot;&lt;/li&gt;&quot;.&quot;&lt;li&gt;&quot;.$children.&quot;&lt;/li&gt;&quot;;
				}
				elseif ( $post-&gt;post_parent == 0 ) {

					echo &quot;&lt;li&gt;&quot;;

					echo the_title().&quot;&lt;/li&gt;&quot;;

				}
			}

			echo &quot;&lt;/ul&gt;&lt;/div&gt;&quot;;
		}
	?&gt;
</pre>
<p>For search result page , you can display the search query instead of &#8220;Search Results&#8221; just use this code </p>
<pre class="brush: php;">
			elseif ( is_search() ) {
				echo &quot;&lt;li&gt;&quot;.the_search_query().&quot;&lt;/li&gt;&quot;;
			}
</pre>
<h3>Finally</h3>
<p>Just use the include function to include the breadcrumbs script any where in your theme .</p>
<pre class="brush: php;">
	&lt;?php include (TEMPLATEPATH . '/breadcrumbs.php'); ?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://banhawi.com/2009/06/wordpress-conditional-tags-in-action-breadcrumbs/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Create Your Own &#8220;kwicks&#8221; jQuery Effect</title>
		<link>http://banhawi.com/2009/06/create-your-own-kwicks-jquery-effect/</link>
		<comments>http://banhawi.com/2009/06/create-your-own-kwicks-jquery-effect/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 12:18:51 +0000</pubDate>
		<dc:creator>Banhawi</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jQuery Navigation Effect]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://banhawi.com/?p=27</guid>
		<description><![CDATA[Today&#8217;s tutorial and my first tutorial here will be about jQuery , i&#8217;m going to explain how to create your own popular &#8220;kwicks&#8221; effect . For those who don&#8217;t know Kwicks jQuery Plugin here&#8217;s a link to it , kwicks plugin was developed by Jeremy Martin .

Demo &#8211; Source


Step One
Let&#8217;s start writing our markup .


&#60;html&#62;
	&#60;head&#62;
		&#60;title&#62;JS [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s tutorial and my first tutorial here will be about jQuery , i&#8217;m going to explain how to create your own popular &#8220;kwicks&#8221; effect . For those who don&#8217;t know Kwicks jQuery Plugin here&#8217;s a <a href="http://www.jeremymartin.name/projects.php?project=kwicks">link</a> to it , kwicks plugin was developed by Jeremy Martin .</p>
<div class="demo">
<a href="http://banhawi.com/demos/jquery/kwicks-clone/Example.html">Demo</a> &#8211; <a href="http://banhawi.com/wp-content/uploads/2009/06/kwicks-clone.zip">Source</a>
</div>
<p><span id="more-27"></span></p>
<h3>Step One</h3>
<p>Let&#8217;s start writing our markup .</p>
<pre class="brush: html;">

&lt;html&gt;
	&lt;head&gt;
		&lt;title&gt;JS Effect&lt;/title&gt;
	&lt;/head&gt;
	&lt;body&gt;
		&lt;ul&gt;
			&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/products.jpg&quot; alt=&quot;&quot;/&gt;&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/history.jpg&quot; alt=&quot;&quot;/&gt;&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/news.jpg&quot; alt=&quot;&quot;/&gt;&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/urideas.jpg&quot; alt=&quot;&quot;/&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>As you see in the code above it&#8217;s just a normal html page containing a ul menu with four &#8220;li&#8221; members , each li containing linked image . Pretty simple is not it ?</p>
<h3>Step Two</h3>
<p>Let&#8217;s write our CSS</p>
<pre class="brush: css;">
			ul li {
				list-style-type: none;
				width: 125px;
				height: 100px;
				margin-right: 10px;
				float: left;
				overflow: hidden;
			}
			a img {
				border: 0;
			}
</pre>
<p>The code above is pretty simple we just styled all &#8220;li&#8221; members and removed the border from linked images .</p>
<h3>Step Three</h3>
<p>Import the jQuery library , simply add this line in within the &lt;head&gt; &lt;/head&gt; tags in your HTML .</p>
<pre class="brush: html;">
&lt;script src=&quot;http://code.jquery.com/jquery-latest.js&quot;&gt;&lt;/script&gt;
</pre>
<h3>Step Four</h3>
<p>This tells the browser to run the functions within the { } when the html document is ready .</p>
<pre class="brush: javascript;">
$(document).ready(function(){

});
</pre>
<h3>Step Five</h3>
<pre class="brush: javascript;">
$(document).ready(function(){
	$(&quot;li&quot;).mouseover(function(){
		$(&quot;li&quot;).animate({ width: &quot;100px&quot;}, 500 );
		$(this).animate({ width: &quot;200px&quot;}, 500 );
	});
});
</pre>
<p>In the code above we used the mouseover event , which means the function that follows $(&#8221;li&#8221;).mouseover will be executed only when you hover on one of the &#8220;li&#8221; members .</p>
<p>Then we use the animate effect   $(&#8221;li&#8221;).animate({ width: &#8220;100px&#8221;}, 500 ); this means animate all &#8220;li&#8221; members using the following css properties which is width:&#8221;100px&#8221; .</p>
<p>After adding your new css  properties you define the speed of the animation which is 500 here , you can add your own speed or you can use slow , normal , fast instead of numbers.</p>
<p>This will animate the &#8220;li&#8221; members from width 125px predefined in the css to the new 100px width with speed of 500 milliseconds .</p>
<p>$(this).animate({ width: &#8220;200px&#8221;}, 500 ); &#8211; $(this) means animate the hovered &#8220;li&#8221; member to width 200px with the speed of 500 milliseconds .</p>
<p>Finally we close the mouseover event }); .</p>
<p>If you tested the code we have done so far you&#8217;ll notice that the &#8220;li&#8221; members first animate to the width of 100px then the hovered one animates to the width of 200px , and this is not good as it may cause a problem when changing the width of the &#8220;li&#8221; members to 100px the cursor may hover on another &#8220;li&#8221; member which will cause animating another &#8220;li&#8221; member , we can fix this by adding different css classes to the &#8220;li&#8221; members when hovered and when not .</p>
<p>so Let&#8217;s Edit the html .</p>
<h3>Step Six</h3>
<pre class="brush: html;">
&lt;ul&gt;
	&lt;li class=&quot;inactive&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/products.jpg&quot; alt=&quot;&quot;/&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;li class=&quot;inactive&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/history.jpg&quot; alt=&quot;&quot;/&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;li class=&quot;inactive&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/news.jpg&quot; alt=&quot;&quot;/&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;li class=&quot;inactive&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/urideas.jpg&quot; alt=&quot;&quot;/&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>Here we have added class=&#8221;inactive&#8221; to all &#8220;li&#8221; members .</p>
<h3>Step Seven</h3>
<p>Now we have defined all un hovered &#8220;li&#8221; members with inactive class , jQuery give us the ability to add css classes using the Attribute addClass and removing css classes using the Attribute removeClass , we will use these Attributes in the next code .</p>
<pre class="brush: javascript;">
$(document).ready(function(){
	$(&quot;li&quot;).mouseover(function(){
		$(this).removeClass(&quot;inactive&quot;);
		$(this).addClass(&quot;active&quot;);
		$(&quot;li.active&quot;).animate({ width: &quot;200px&quot;}, 500 );
		$(&quot;li.inactive&quot;).animate({ width: &quot;100px&quot;}, 500 );
	});
});
</pre>
<p>First and second line we explained before .</p>
<p>Third line $(this).removeClass(&#8221;inactive&#8221;); mean remove &#8220;inactive&#8221; css class from hovered &#8220;li&#8221; member .</p>
<p>Fourth line $(this).addClass(&#8221;active&#8221;); mean add &#8220;active&#8221; css class to hovered &#8220;li&#8221; member .</p>
<p>Fifth line $(&#8221;li.active&#8221;).animate({ width: &#8220;200px&#8221;}, 500 ); animates the active hovered &#8220;li&#8221; member to the new 200px width with speed of 500 millisecond.</p>
<p>Sixth line $(&#8221;li.inactive&#8221;).animate({ width: &#8220;100px&#8221;}, 500 ); animates the inactive unhovered &#8220;li&#8221; member to the new 100px width with speed of 500 millisecond .</p>
<p>Then we close our events .</p>
<h3>Step Eight</h3>
<p>Approximately we are done , but there&#8217;s a problem which is when we hover on one of the &#8220;li&#8221; it animates to the new width of 200px and the other unhovered &#8220;li&#8221; members to the new 100px width and this is not good because when take the cursor away of the &#8220;li&#8221; member , all the &#8220;li&#8221; members stay with new widths , we want them animate back to the original widths when we take the cursor away of the &#8220;li&#8221; members , so we have to write the next code  after  $(&#8221;li&#8221;).mouseover(function(){ &#8230; });</p>
<pre class="brush: javascript;">
$(&quot;li&quot;).mouseout(function(){
	$(this).removeClass(&quot;active&quot;);
	$(this).addClass(&quot;inactive&quot;);
	$(&quot;li&quot;).animate({ width: &quot;125px&quot;}, 500 );
});
</pre>
<p>In the above code we used a new event called mouseout which mean do the involved function when taking the cursor away of &#8220;li&#8221; member .</p>
<p>Second line $(this).removeClass(&#8221;active&#8221;); means remove the &#8220;active&#8221; css class from the was hovered &#8220;li&#8221; member .</p>
<p>Third line $(this).addClass(&#8221;inactive&#8221;); means add the &#8220;inactive&#8221; css class to the was hovered &#8220;li&#8221; member .</p>
<p>Fourth line $(&#8221;li&#8221;).animate({ width: &#8220;125px&#8221;}, 500 ); animates all the &#8220;li&#8221; members to the original width of 125px with the speed of 500 milliseconds .</p>
<p>After that we close the mouseout event .</p>
<h3>Extra Step</h3>
<p>Be creative , we&#8217;ve created so far  just a width expanding ul menu , you can add height to the animate effect function and your ul menu will expand in both dimensions .<br />
Here&#8217;s will be the new jquery code </p>
<pre class="brush: javascript;">
  		$(document).ready(function(){
    		$(&quot;li&quot;).mouseover(function(){
   				$(this).removeClass(&quot;inactive&quot;);
   				$(this).addClass(&quot;active&quot;);
        		$(&quot;li.active&quot;).animate({ width: &quot;200px&quot;,height: &quot;120px&quot;}, 500 );
      			$(&quot;li.inactive&quot;).animate({ width: &quot;100px&quot;,height: &quot;100px&quot;}, 500 );
      		});
      		$(&quot;li&quot;).mouseout(function(){
    			$(this).removeClass(&quot;active&quot;);
   				$(this).addClass(&quot;inactive&quot;);
      			$(&quot;li&quot;).animate({ width: &quot;125px&quot;,height: &quot;100px&quot;}, 500 );
    		});
  		});
</pre>
<div class="demo">
<a href="http://banhawi.com/demos/jquery/kwicks-clone/yet-another-example.html">Yet Another Example</a>
</div>
<h3>Read More</h3>
<ul>
<li>http://docs.jquery.com/Events/</li>
<li>http://docs.jquery.com/Attributes/</li>
<li>http://docs.jquery.com/API/1.3/Effects</li>
]]></content:encoded>
			<wfw:commentRss>http://banhawi.com/2009/06/create-your-own-kwicks-jquery-effect/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>
