<?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>Web Design / Development &#124; FLDtrace</title>
	<atom:link href="http://www.fldtrace.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.fldtrace.com</link>
	<description></description>
	<lastBuildDate>Thu, 29 Jul 2010 19:10:51 +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>Center a DropDown Menu Using CSS and JQUERY</title>
		<link>http://www.fldtrace.com/css/center-a-dropdown-menu-using-css-and-jquery</link>
		<comments>http://www.fldtrace.com/css/center-a-dropdown-menu-using-css-and-jquery#comments</comments>
		<pubDate>Sat, 12 Jun 2010 17:24:52 +0000</pubDate>
		<dc:creator>Lucian</dc:creator>
				<category><![CDATA[Css]]></category>
		<category><![CDATA[Jquery]]></category>

		<guid isPermaLink="false">http://www.fldtrace.com/?p=844</guid>
		<description><![CDATA[Maybe you have noticed that majority of the drop-down menus on the web, are aligned to the left of their containing parent. Using Jquery, we will position the dropdown in the middle of the parent, dynamically centered, no matter how long the parent's link width gets. Since the dropdowns are positioned absolutely, the CSS <strong>margin: auto</strong> won't help in our case.

Using this method, we can have an interesting design, with an arrow pointing up or you can come up with other design ideas. Also, for users without Javascript enabled in their browsers, the navigation will degrade gracefully and the positioning will be to the left of the parent.

<strong><a href="http://www.pixeldelirious.com/wp-content/themes/static/" class="feather_link">View Demo</a></strong>


Related posts:<ol><li><a href='http://www.fldtrace.com/css/better-techniques-for-writing-css-and-markup' rel='bookmark' title='Permanent Link: Better techniques for writing CSS and markup'>Better techniques for writing CSS and markup</a></li>
<li><a href='http://www.fldtrace.com/wordpress/float-images-in-wordpress-properly' rel='bookmark' title='Permanent Link: Float images in WordPress properly'>Float images in WordPress properly</a></li>
<li><a href='http://www.fldtrace.com/wordpress/how-to-display-dynamic-menu-in-wordpress' rel='bookmark' title='Permanent Link: How To Display Dynamic Menu Pages In WordPress'>How To Display Dynamic Menu Pages In WordPress</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h2>Create the markup</h2>
<p>Go ahead and paste the following HTML code in your HTML file:<span id="more-844"></span></p>
<p>


<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">        	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nav&quot;</span>&gt;</span>
            	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Home<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
                <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Apple News<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
                	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
                    	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>iPhone<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
                        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>iMac<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
                        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Apple<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
                    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
                <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
                <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>iPhone App Reviews<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
                	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
                    	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Echofon<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
                        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Shazam<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
                        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Urban Spoon<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
                    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
                <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
                <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span></pre></div></div>



</p>
<h2>Style the navigation and dropdown with CSS</h2>
<p>The following CSS code, will ensure that the dropdown looks and works properly. Also we will add a pointer arrow image and do some CSS tricks, so we can have the arrow centered at the top of the dropdown.</p>
<p>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*main nav*/</span>
<span style="color: #cc00cc;">#nav</span> li <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #cc00cc;">#nav</span> a <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">30px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">15px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">1.4em</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#9F8F79</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">&#125;</span>
		<span style="color: #cc00cc;">#nav</span> a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#f2f2f2</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #808080; font-style: italic;">/*dropdown*/</span>
	ul<span style="color: #cc00cc;">#nav</span> ul <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">36px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#e3e3e3</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">i/pointer-drop-down.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #933;"><span style="color: #cc66cc;">50</span>%</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">z-index</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">100</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		ul<span style="color: #cc00cc;">#nav</span> ul li <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#5b544a</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#6e6659</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
		ul<span style="color: #cc00cc;">#nav</span> ul li<span style="color: #3333ff;">:first-child </span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">border-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/*dropdown*/</span>
		ul<span style="color: #cc00cc;">#nav</span> ul li<span style="color: #3333ff;">:last-child </span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">padding-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">35px</span><span style="color: #00AA00;">&#125;</span> 
			ul<span style="color: #cc00cc;">#nav</span> ul li a <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">148px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#5b544a</span><span style="color: #00AA00;">&#125;</span>
			<span style="color: #808080; font-style: italic;">/*the magic*/</span>
			ul<span style="color: #cc00cc;">#nav</span> li<span style="color: #3333ff;">:hover </span>ul<span style="color: #00AA00;">,</span> ul<span style="color: #cc00cc;">#nav</span> li<span style="color: #3333ff;">:focus </span>ul <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">&#125;</span></pre></div></div>



</p>
<h2>The Jquery centers what CSS cannot</h2>
<p>First we need to include the Jquery library. My preferred method, is by using the Google CDN, as it loads faster that way. At the top of your HTML file, within the <strong>head</strong> tag, add the following:</p>
<p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>



</p>

<p>The very next thing we need to add will be our code:</p>
<p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
	$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul#nav li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">mouseover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> the_width <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> child_width <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> width <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>child_width <span style="color: #339933;">-</span> the_width<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'left'</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span>width<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>



</p>

<h3>Browser support</h3>
<p>It works well in all of the major browsers, including IE7+. In IE6 the drop-down does not show up but there are <a href="http://www.alistapart.com/articles/dropdowns">fixes</a> for that and the dropdown will still show up centered, after we apply the fix.</p>

<h3>Your opinion</h3>
<p>Let me know how it works for you or if you have any questions regarding the method.</p> <img src="http://www.fldtrace.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=844" width="1" height="1" style="display: none;" />

<p>Related posts:<ol><li><a href='http://www.fldtrace.com/css/better-techniques-for-writing-css-and-markup' rel='bookmark' title='Permanent Link: Better techniques for writing CSS and markup'>Better techniques for writing CSS and markup</a></li>
<li><a href='http://www.fldtrace.com/wordpress/float-images-in-wordpress-properly' rel='bookmark' title='Permanent Link: Float images in WordPress properly'>Float images in WordPress properly</a></li>
<li><a href='http://www.fldtrace.com/wordpress/how-to-display-dynamic-menu-in-wordpress' rel='bookmark' title='Permanent Link: How To Display Dynamic Menu Pages In WordPress'>How To Display Dynamic Menu Pages In WordPress</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.fldtrace.com/css/center-a-dropdown-menu-using-css-and-jquery/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Float images in WordPress properly</title>
		<link>http://www.fldtrace.com/wordpress/float-images-in-wordpress-properly</link>
		<comments>http://www.fldtrace.com/wordpress/float-images-in-wordpress-properly#comments</comments>
		<pubDate>Sun, 30 May 2010 21:51:23 +0000</pubDate>
		<dc:creator>Lucian</dc:creator>
				<category><![CDATA[Css]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.fldtrace.com/?p=821</guid>
		<description><![CDATA[In the following article, I will explain a method to make it easy for you or for your clients, to float multiple images left, in Wordpress.

The method is useful if you want to float images left, on sections such as team bio, where the member will have his/her image left and a bio text aside right.

The alternative, dirty way to do it, would be using tables, but the code is bulky, harder to maintain,  page  loads slower and definitely not the easiest way to do it. Read on for the good method.


Related posts:<ol><li><a href='http://www.fldtrace.com/wordpress/load-javascript-on-specific-pages-in-wordpress' rel='bookmark' title='Permanent Link: How to load Javascript on specific pages in WordPress'>How to load Javascript on specific pages in WordPress</a></li>
<li><a href='http://www.fldtrace.com/css/center-a-dropdown-menu-using-css-and-jquery' rel='bookmark' title='Permanent Link: Center a DropDown Menu Using CSS and JQUERY'>Center a DropDown Menu Using CSS and JQUERY</a></li>
<li><a href='http://www.fldtrace.com/css/better-techniques-for-writing-css-and-markup' rel='bookmark' title='Permanent Link: Better techniques for writing CSS and markup'>Better techniques for writing CSS and markup</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h2>Float images left in WordPress editor<span id="more-821"></span></h2>
<p>Down below, there is an example with how the final result will look. You can see how the logo images wrap around text nicely.</p>
<p><a href="http://www.fldtrace.com/wp-content/uploads/2010/05/floats-results.jpg" rel="shadowbox[post-821];player=img;"><img src="http://www.fldtrace.com/wp-content/uploads/2010/05/floats-results.jpg" alt="" title="floats-results" width="590" height="390" class="alignnone img_border size-full wp-image-820" /></a></p>

<h3>Include WordPress default styles and clear the float</h3>
<p>When you develop custom themes for WordPress, it is very likely you will replace the whole code from <strong>style.css</strong>, which is a good practice actually.</p>
<p>However, there are some styles that are recommended to be preserved, so we can float elements. The only styles we need to add to our style.css file, are:</p>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">.alignleft<span style="color: #00AA00;">,</span>
img<span style="color: #6666ff;">.alignleft</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.5em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
.alignright<span style="color: #00AA00;">,</span>
img<span style="color: #6666ff;">.alignright</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.5em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
.aligncenter<span style="color: #00AA00;">,</span>
img<span style="color: #6666ff;">.aligncenter</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">clear</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">both</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
p <span style="color: #00AA00;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">clear</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">both</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>




<p>Notice that last line <strong>clear: both</strong>, clears the floated image inside the paragraph and prevents it to wrap around a previous element in page.</p>

<h3>Wrap an image left in WordPress editor</h3>

<p>Now, when we edit a page or a post:</p> 
<ul>
<li>we need to insert the image</li> 
<li>select it</li> 
<li>click the <strong>align left button</strong> and make sure it will show up on a single line (that means the image and the text, are located in the same paragraph so they can wrap around). When you click align left button, a class <strong>.aligncenter</strong> is added automatically.</li>
</ul>
<p>In this example, I floated images left, but they can be floated right as well, using the same method, by clicking the align right button instead.</p>
<p>At this point, I assume you already know how to upload and include images in your WordPress editor.</p>
<p><a href="http://www.fldtrace.com/wp-content/uploads/2010/05/float-image-left.jpg" rel="shadowbox[post-821];player=img;"><img src="http://www.fldtrace.com/wp-content/uploads/2010/05/float-image-left.jpg" alt="" title="float-image-left" width="590" height="390" class="alignnone img_border size-full wp-image-817" /></a></p>

<h3>Float multiple images left</h3>
<p>Now we can float more images to the left of the text, using the method described above. They will show up nice within the main website, since we have have specified <strong>clear: both</strong> for the paragraphs.</p>
<p>WordPress TINYMCE editor, uses other stylesheet than the one you use for the main website and <em>it doesn&#8217;t know</em>, that floats are supposed to be cleared within paragraphs.</p>
<p><a href="http://www.fldtrace.com/wp-content/uploads/2010/05/float-multiple-images-left.jpg" rel="shadowbox[post-821];player=img;"><img src="http://www.fldtrace.com/wp-content/uploads/2010/05/float-multiple-images-left.jpg" alt="" title="float-multiple-images-left" width="590" height="390" class="alignnone size-full wp-image-819 img_border" /></a></p>

<h2>Customize the TinyMCE WordPress editor</h2>
<p>While this step is optional, I find it is very easy for the clients to get a feel of how content looks like before publishing, they won&#8217;t get confused and will have great experience while editing their websites.</p>
<h3>TinyMCE WordPress editor &#8211; the polished final look</h3>
<p><a href="http://www.fldtrace.com/wp-content/uploads/2010/05/customized-editor.jpg" rel="shadowbox[post-821];player=img;"><img src="http://www.fldtrace.com/wp-content/uploads/2010/05/customized-editor.jpg" alt="" title="customized-editor" width="590" height="390" class="alignnone img_border size-full wp-image-816" /></a></p>

<h3>Code for WordPress editor styling</h3>
<p>First we need to create a CSS file in our theme file. I am gonna create a folder called css,  a file name <strong>editor-style.css</strong> and add the following code in it:</p>

<h4>Basic CSS code</h4>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*image float CSS clear*/</span>
<span style="color: #6666ff;">.mceContentBody</span> p <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">clear</span><span style="color: #00AA00;">:</span><span style="color: #993333;">both</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">20px</span> <span style="color: #933;">25px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #6666ff;">.mceContentBody</span> p img <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">20px</span> <span style="color: #933;">25px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#125;</span></pre></div></div>




<h4>Enhanced CSS code</h4>
<p>This code is optional only, and the code from above is enough to show up floats properly, but it will look great if we customize the text color for headings, normal text and basic links; the width of the content will match the one of the website as well.</p>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*general CSS text and links styles for Wordpress editor*/</span>
<span style="color: #6666ff;">.mceContentBody</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Trebuchet MS<span style="color: #00AA00;">,</span> Verdana<span style="color: #00AA00;">,</span> Arial<span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span> !important<span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">18px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">590px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.mceContentBody</span> h1<span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.mceContentBody</span> h3<span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.mceContentBody</span> h4<span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.mceContentBody</span> h5<span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.mceContentBody</span> h6 <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#1f201c</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.mceContentBody</span> h2 <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#f78a20</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #6666ff;">.mceContentBody</span> h2<span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.mceContentBody</span> h4 <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">italic</span><span style="color: #00AA00;">&#125;</span>
body<span style="color: #6666ff;">.mceContentBody</span> a <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#f78a20</span> !important<span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*image float CSS clear*/</span>
<span style="color: #6666ff;">.mceContentBody</span> p <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">clear</span><span style="color: #00AA00;">:</span><span style="color: #993333;">both</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">20px</span> <span style="color: #933;">25px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #6666ff;">.mceContentBody</span> p img <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">20px</span> <span style="color: #933;">25px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#125;</span></pre></div></div>




<h3>Load our custom CSS editor file</h3>
<p><strong>[Update: starting with wordpress 3.0 editor-style.css is part of theme and is not necessary to load it using the code from below (make sure you enable the editor-style.css by adding <em>add_editor_style();</em> in functions.php).</strong></p> 
<p><strong>However, the following snippet is useful if you still use an older version of WordPress.]</strong></p>
<p>In order to make it look that way, we need to add this snippet to <strong>functions.php file</strong>, located in our theme folder. Don&#8217;t forget to edit the link inside to match the location of our custom editor CSS file.</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//CUSTOM WORDPRESS EDITOR STYLE</span>
<span style="color: #000000; font-weight: bold;">function</span> custom_editor_style<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$url</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: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #000088;">$url</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">','</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// Edit path to match the custom style location. Currently the file is located in active theme, in a folder called css.</span>
  <span style="color: #000088;">$url</span> <span style="color: #339933;">.=</span> trailingslashit<span style="color: #009900;">&#40;</span> get_stylesheet_directory_uri<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'css/editor-style.css'</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$url</span><span style="color: #339933;">;</span>  
<span style="color: #009900;">&#125;</span> 
  add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'mce_css'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'custom_editor_style'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// END CUSTOM WORDPRESS EDITOR STYLE</span></pre></div></div>



<p>Thanks to <a href="http://matty.co.za/2010/05/editor-style-in-wordpress/">Matty</a> for the code snippet. You can learn more about this method on his website.</p>

<h2>Your feedback</h2>
<p>Please let me know how everything works for you, using the comment form below.</p> <img src="http://www.fldtrace.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=821" width="1" height="1" style="display: none;" />

<p>Related posts:<ol><li><a href='http://www.fldtrace.com/wordpress/load-javascript-on-specific-pages-in-wordpress' rel='bookmark' title='Permanent Link: How to load Javascript on specific pages in WordPress'>How to load Javascript on specific pages in WordPress</a></li>
<li><a href='http://www.fldtrace.com/css/center-a-dropdown-menu-using-css-and-jquery' rel='bookmark' title='Permanent Link: Center a DropDown Menu Using CSS and JQUERY'>Center a DropDown Menu Using CSS and JQUERY</a></li>
<li><a href='http://www.fldtrace.com/css/better-techniques-for-writing-css-and-markup' rel='bookmark' title='Permanent Link: Better techniques for writing CSS and markup'>Better techniques for writing CSS and markup</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.fldtrace.com/wordpress/float-images-in-wordpress-properly/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Better techniques for writing CSS and markup</title>
		<link>http://www.fldtrace.com/css/better-techniques-for-writing-css-and-markup</link>
		<comments>http://www.fldtrace.com/css/better-techniques-for-writing-css-and-markup#comments</comments>
		<pubDate>Fri, 14 May 2010 20:04:04 +0000</pubDate>
		<dc:creator>Lucian</dc:creator>
				<category><![CDATA[Css]]></category>

		<guid isPermaLink="false">http://www.fldtrace.com/?p=779</guid>
		<description><![CDATA[A website speed performance depends mainly on the quality of the CSS and markup code behind it. (JavaScript as well but this part will not be covered in this post.)

The websites with a clean code are also easier to maintain, saving time to the developer and money to the client, that's why I find extremely important to write the (X)HTML and CSS efficiently.

While there are more website layouts types: fixed-width, fluid (liquid), elastic, hybrid, it is important to choose the layout which suits best for the website target audience.

The most popular is fixed-width layout, which allows to take the design and preserve the appearance to the pixel, that's why me and most coders out there choose it.


Related posts:<ol><li><a href='http://www.fldtrace.com/wordpress/float-images-in-wordpress-properly' rel='bookmark' title='Permanent Link: Float images in WordPress properly'>Float images in WordPress properly</a></li>
<li><a href='http://www.fldtrace.com/css/center-a-dropdown-menu-using-css-and-jquery' rel='bookmark' title='Permanent Link: Center a DropDown Menu Using CSS and JQUERY'>Center a DropDown Menu Using CSS and JQUERY</a></li>
<li><a href='http://www.fldtrace.com/wordpress/include-different-sidebar-in-wordpress-depending-on-section' rel='bookmark' title='Permanent Link: Include different sidebar in WordPress, depending on the section you are'>Include different sidebar in WordPress, depending on the section you are</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Next, I will share with you several coding techniques that will increase productivity and will generate websites that will work good in all major browsers.<span id="more-779"></span></p>
<h2>Write the CSS before the HTML markup</h2>
<p>When I first started, I was building the HTML markup, thereafter writing the CSS for it, having to go back and forth several times between the CSS and HTML.</p>
<p>Now, I found out I am more efficient and much faster if I specify the CSS first. After you specify the id, classes and their attributes in the stylesheet file, it is easier to go and add the HTML.</p>
<p>The advantage is  that you will have specified the appearance of the elements in page. If you choose to write the HTML structure and move on to CSS, you might figure out that some HTML need to be re-organized to accommodate the CSS styles, slowing you down.
As analogy, you first need to specify the house plan before you can start the foundation and building the house.</p>
<h2>CSS Reset before anything else</h2>
<p>The browsers are styling differently the elements within a website, so if you want to save time and headaches in future, the first thing to do, is add a master CSS reset.</p>
<p>Erick Meyer has the most popular <a href="http://meyerweb.com/eric/tools/css/reset/">CSS reset</a>.</p>
<p>However, that is too long and general for my projects and I came up with a shorter and efficient one which suites better for the websites I work on:</p>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* RESET */</span>
html<span style="color: #00AA00;">,</span>body<span style="color: #00AA00;">,</span>div<span style="color: #00AA00;">,</span>ul<span style="color: #00AA00;">,</span>ol<span style="color: #00AA00;">,</span>li<span style="color: #00AA00;">,</span>dl<span style="color: #00AA00;">,</span>dt<span style="color: #00AA00;">,</span>dd<span style="color: #00AA00;">,</span>h1<span style="color: #00AA00;">,</span>h2<span style="color: #00AA00;">,</span>h3<span style="color: #00AA00;">,</span>h4<span style="color: #00AA00;">,</span>h5<span style="color: #00AA00;">,</span>h6<span style="color: #00AA00;">,</span>pre<span style="color: #00AA00;">,</span>form<span style="color: #00AA00;">,</span>p<span style="color: #00AA00;">,</span>blockquote<span style="color: #00AA00;">,</span>fieldset<span style="color: #00AA00;">,</span>input <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
h1<span style="color: #00AA00;">,</span>h2<span style="color: #00AA00;">,</span>h3<span style="color: #00AA00;">,</span>h4<span style="color: #00AA00;">,</span>h5<span style="color: #00AA00;">,</span>h6<span style="color: #00AA00;">,</span>pre<span style="color: #00AA00;">,</span>code<span style="color: #00AA00;">,</span>address<span style="color: #00AA00;">,</span>caption<span style="color: #00AA00;">,</span>cite<span style="color: #00AA00;">,</span>code<span style="color: #00AA00;">,</span>th <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
ul<span style="color: #00AA00;">,</span>ol<span style="color: #00AA00;">,</span>li <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
fieldset<span style="color: #00AA00;">,</span>img <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
caption<span style="color: #00AA00;">,</span>th <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
table <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border-collapse</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">collapse</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-spacing</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>



<h2>Floats clearfix</h2>
<p>There are two layout coding techniques which are mostly used for fixed-width layouts: floats and absolute positioning.</p>
<p>At the present time, the floating technique is the best method of building expanding websites, where the height adjust dynamic based on content.</p>
<p>Absolute positioning alone is still useful and sometimes critical at certain times, for arranging elements (e.g elements position in a header with specific height are easier to be specified using absolute positioning than floating).</p>
<h3>Clearfix float code</h3>
<p>As you may already have know, the floats needs to be cleared, usually inserting the following code after a floated element, which will stop the others elements wrap it.:</p>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">&lt;br <span style="color: #000000; font-weight: bold;">clear</span><span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;both&quot;</span><span style="color: #00AA00;">&gt;</span></pre></div></div>


 
<p>A big time and markup saver is the <strong>clearfix method</strong>, the only thing to do is to specify the following code in your CSS file:</p>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.clearfix</span><span style="color: #3333ff;">:after </span><span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">content</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #00AA00;">;</span> 
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> 
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> 
    <span style="color: #000000; font-weight: bold;">clear</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">both</span><span style="color: #00AA00;">;</span> 
    <span style="color: #000000; font-weight: bold;">visibility</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.clearfix</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> inline-<span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* Hides from IE-mac \*/</span>
<span style="color: #00AA00;">*</span> html <span style="color: #6666ff;">.clearfix</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">1</span>%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.clearfix</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #808080; font-style: italic;">/* End hide from IE-mac */</span></pre></div></div>




<p>Than, all of the parent elements that contain at least 2 floating elements need to get a class=&#8221;clearfix&#8221;.</p>
<p>You can find out more at this article: <a href="http://www.positioniseverything.net/easyclearing.html">How To Clear Floats Without Structural Markup</a>.</p>
<h3>IE 6 support not that hard</h3>
<p>Using the method specified above the bugs for IE6 are minimal and easy to fix.</p>
<p>I have encountered consistently 2 bugs in IE6 and those are:</p>
<ul>
<li>
<a href="http://www.positioniseverything.net/explorer/doubled-margin.html">Double margin float bug</a> which can be fixed by specifying <strong>display: inline</strong> for the affected float.
</li>
<li><a href="http://www.positioniseverything.net/explorer/dup-characters.html">IE6 duplicate characters bug</a> which shows up when you have html comments between the floats. Weird enough, I decided I will not comment my HTML anymore, that way I can minimize the file size. Instead of commenting the HTML I found out that indentation is more important. However, I still comment the CSS file where we usually spend at least 80% of the time when building a website.</li>
</ul><br />
<h2>Single line / hybrid CSS formatting rules</h2>
<p>There are <a href="http://css-tricks.com/different-ways-to-format-css/">multiple ways of formatting the CSS</a>: multi-line, single line, hybrid etc.</p>
<p>While some coders have their own preference, in my opinion, the single line formatting is the best from all:</p>
<ul>
<li>File size is reduced, the website will load faster;</li>
<li>The code is easier to read and spot. Imagine how hard is to find elements in a multi-line CSS file and how much scrolling needs to be done;</li>
</ul>
<p>I still have some parts of my code (around 10%) formatted as multi-line that&#8217;s why I call it hybrid.</p>

<h2>Other CSS tips and tricks</h2>
<h3>Use of starter files: CSS, HTML</h3>
<p>If you are building websites for some time now, I guess you already found out that you need to repeat a lot of code. To avoid that for future projects, a great practice is creation of basic starter files as: <strong>index.html</strong>, <strong>style.css</strong>, <strong>a folder for images</strong> called <strong>i</strong> by the way, <strong>a folder for scripts</strong>, <strong>a robots.txt file</strong> and maybe a <strong>.htaccess file</strong>.</p>
<p>Inside the CSS file you should have the clearfix and reset code portions we have mentioned above, plus some basic styling for layout elements such header, container, nav, sidebar, footer and other elements you are using often.</p>

<h3>One single CSS file &#8211; no @import</h3>
<p>I like to organize my CSS in one single file, that way it is much more easier to maintain, instead of searching in few other different files.</p>
<p>In case you are the one who likes to have the CSS organized in more files, you should also know that @import is not recommended and the use of <strong>style</strong> tag within <strong>head</strong> tags, is better.</p>

<h3>Images folder name should be short</h3>
<p>The folder where I store my images has a really short name, actually one letter: <strong>i</strong>. That way, whenever I have to call images in my CSS on the mark-up will take me lesser time and will result in reduced code.</p>

<h3>Unnecessary CSS selectors</h3>
<p>The golden rule is: never be too specific when you don&#8217;t have to be.</p>
<p>For example, when you are working the navigation there is no reason to specify the styles for the links like following:
<strong>ul#nav li a</strong>, instead <strong>#nav a</strong> is better practice. It will also take lesser code to specify the styles for nested elements, such as drop-downs and easier to mange the code.
</p>

<h3>Unordered lists are better than div block in certain cases</h3>
<p>While the <strong>div</strong> tags are used mainly for organizing the markup, <strong>ul</strong> will keep the mark-up shorter for certain elements: navigations, footer elements etc. Using unordered lists is not only advised, but is a technique used by all experienced coders.</p>

<h2>Your opinion</h2>
<p>Please comment below what other tricks you are using when coding websites, for maximizing productivity and quality.</p> <img src="http://www.fldtrace.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=779" width="1" height="1" style="display: none;" />

<p>Related posts:<ol><li><a href='http://www.fldtrace.com/wordpress/float-images-in-wordpress-properly' rel='bookmark' title='Permanent Link: Float images in WordPress properly'>Float images in WordPress properly</a></li>
<li><a href='http://www.fldtrace.com/css/center-a-dropdown-menu-using-css-and-jquery' rel='bookmark' title='Permanent Link: Center a DropDown Menu Using CSS and JQUERY'>Center a DropDown Menu Using CSS and JQUERY</a></li>
<li><a href='http://www.fldtrace.com/wordpress/include-different-sidebar-in-wordpress-depending-on-section' rel='bookmark' title='Permanent Link: Include different sidebar in WordPress, depending on the section you are'>Include different sidebar in WordPress, depending on the section you are</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.fldtrace.com/css/better-techniques-for-writing-css-and-markup/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Show subpages only for the current parent page in WordPress</title>
		<link>http://www.fldtrace.com/wordpress/show-subpages-for-the-current-parent-page-in-wordpress</link>
		<comments>http://www.fldtrace.com/wordpress/show-subpages-for-the-current-parent-page-in-wordpress#comments</comments>
		<pubDate>Mon, 19 Apr 2010 14:28:37 +0000</pubDate>
		<dc:creator>Lucian</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.fldtrace.com/?p=756</guid>
		<description><![CDATA[Have you ever tried in Wordpress, to list only the sub pages of the current parent page and hide the sub pages of the other parent pages?

I had few people asking me how I realized toggling the subpage navigation links in <a href="http://www.jointuse.org/resources/make-joint-use-happen/answers-to-hard-questions/">following website</a>.

If you notice, the other parent sub pages are hidden. If you go instead on <a href="http://www.jointuse.org/resources/policy/ca-funding-framework/">other subpage</a>, it will hide the others and show up the sub-pages of the current page.


Related posts:<ol><li><a href='http://www.fldtrace.com/wordpress/how-to-display-parent-page-title-in-wordpress' rel='bookmark' title='Permanent Link: How To Display Parent Page Title in WordPress'>How To Display Parent Page Title in WordPress</a></li>
<li><a href='http://www.fldtrace.com/wordpress/bbpress-front-page-text-plugin' rel='bookmark' title='Permanent Link: BBpress Front Page Text Plugin'>BBpress Front Page Text Plugin</a></li>
<li><a href='http://www.fldtrace.com/wordpress/how-to-display-dynamic-menu-in-wordpress' rel='bookmark' title='Permanent Link: How To Display Dynamic Menu Pages In WordPress'>How To Display Dynamic Menu Pages In WordPress</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h2>WordPress sub pages toggle samples<span id="more-756"></span></h2>
<p>In the images from below, you can see how the subpages expand only for the active parent page.</p>
<p>
<img src="http://www.fldtrace.com/wp-content/uploads/2010/04/sub-page-1.png" alt="" title="sub-page-1" width="187" height="261" class="alignleft size-full wp-image-758" />
<img src="http://www.fldtrace.com/wp-content/uploads/2010/04/sub-page-2.png" alt="" title="sub-page-2" width="187" height="261" class="alignleft size-full wp-image-759" />
</p>

<h2>The breadcrumb plugin</h2>
<p>First thing to do is to download the <a href="http://www.fldtrace.com/wp-content/uploads/2010/04/fold-page-list.zip">modified fold list page plugin</a>, unzip and just copy in the WordPress plugins folder, than activate in the back-end.</p>
<p>The plugin itself contains some modifications in order to achieve the desired functionality so you might want to download this version and never upgrade (the development has been discontinued in 2008 anyways).</p>

<h2>The code to call in your template files</h2>

<p>You can integrate it in a sidebar or anywhere you want to have it displayed.</p>
<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: #000088;">$g_page_id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_queried_object_id</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$ancestorIDs</span> <span style="color: #339933;">=</span> _wswwpx_page_get_ancestor_ids<span style="color: #009900;">&#40;</span><span style="color: #000088;">$g_page_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;div class=&quot;sublinks&quot;&gt;&lt;ul&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> wswwpx_fold_page_list <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'depth=2&amp;sort_column=menu_order&amp;title_li=&amp;child of='</span><span style="color: #339933;">.</span><span style="color: #000088;">$ancestorIDs</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/ul&gt;&lt;/div&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>

<h3>The CSS</h3>

<p>Please read the comments that come along with the code for a better understanding:</p>
<p>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#sidebar_subpage</span> ul ul <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">2px</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">&#125;</span>	<span style="color: #808080; font-style: italic;">/*this will create some left space for the subpages links*/</span>	
		<span style="color: #cc00cc;">#sidebar_subpage</span> a <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/*default link style*/</span>		 
		<span style="color: #cc00cc;">#sidebar_subpage</span> a<span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#sidebar_subpage</span> a<span style="color: #3333ff;">:focus</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#sidebar_subpage</span> li<span style="color: #6666ff;">.current_page_item</span> a<span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#sidebar_subpage</span> li<span style="color: #6666ff;">.current_page_ancestor</span> a <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#00aef0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/*hover and current page link style*/</span>
&nbsp;
			<span style="color: #808080; font-style: italic;">/*color fix for subpages - will fix CSS inheritance colors for the subpages links*/</span>
			<span style="color: #cc00cc;">#sidebar_subpage</span> li<span style="color: #6666ff;">.page_item</span> li<span style="color: #6666ff;">.page_item</span> a <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">&#125;</span>			
			<span style="color: #cc00cc;">#sidebar_subpage</span> li<span style="color: #6666ff;">.page_item</span> li<span style="color: #6666ff;">.page_item</span> a<span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#sidebar_subpage</span> li<span style="color: #6666ff;">.page_item</span> li<span style="color: #6666ff;">.page_item</span> a<span style="color: #3333ff;">:focus</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#sidebar_subpage</span> li<span style="color: #6666ff;">.page_item</span> li<span style="color: #6666ff;">.current_page_item</span> a	<span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#00aef0</span><span style="color: #00AA00;">&#125;</span></pre></div></div>



</p>

<h2>WordPress version support</h2>
<p>At this moment the page list folder plugin, which makes this functionality possible, has been tested with WordPress 2.7.1 up to WordPress 2.9.2 and it works.</p>
<p>It is very likely to work with the WordPress 3.0 and other future versions to come, but not guaranteed.</p>

<h3>Questions?</h3>
<p>If you have any questions, please use the comment form below.</p>
<p>Also don&#8217;t forget to check the article: <a href="http://www.fldtrace.com/wordpress/how-to-display-parent-page-title-in-wordpress">how to display parent page title in wordpress</a>.</p> <img src="http://www.fldtrace.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=756" width="1" height="1" style="display: none;" />

<p>Related posts:<ol><li><a href='http://www.fldtrace.com/wordpress/how-to-display-parent-page-title-in-wordpress' rel='bookmark' title='Permanent Link: How To Display Parent Page Title in WordPress'>How To Display Parent Page Title in WordPress</a></li>
<li><a href='http://www.fldtrace.com/wordpress/bbpress-front-page-text-plugin' rel='bookmark' title='Permanent Link: BBpress Front Page Text Plugin'>BBpress Front Page Text Plugin</a></li>
<li><a href='http://www.fldtrace.com/wordpress/how-to-display-dynamic-menu-in-wordpress' rel='bookmark' title='Permanent Link: How To Display Dynamic Menu Pages In WordPress'>How To Display Dynamic Menu Pages In WordPress</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.fldtrace.com/wordpress/show-subpages-for-the-current-parent-page-in-wordpress/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Include different sidebar in WordPress, depending on the section you are</title>
		<link>http://www.fldtrace.com/wordpress/include-different-sidebar-in-wordpress-depending-on-section</link>
		<comments>http://www.fldtrace.com/wordpress/include-different-sidebar-in-wordpress-depending-on-section#comments</comments>
		<pubDate>Sun, 21 Feb 2010 18:21:37 +0000</pubDate>
		<dc:creator>Lucian</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.fldtrace.com/wordpress/include-different-sidebar-in-wordpress-depending-on-section-you-are</guid>
		<description><![CDATA[If / else statements are programming language logic and is something that will help us create better Wordpress custom themes.

A client of mine, wanted to improve his Wordpress site and decided he wants to display different sidebar information depending on the page or section the visitor is.

For example, he wanted to have blog related links as: latest posts, categories and tags, being displayed only on blog section (blog index, categories view, single post view etc). On products/services page and its sub-pages, he decided he wants to have displayed the sub-pages of that section and other interesting links. The rest of the pages, should have only the interesting links section or generic information.


Related posts:<ol><li><a href='http://www.fldtrace.com/wordpress/8-recommended-useful-plugins-for-wordpress' rel='bookmark' title='Permanent Link: 8 Recommended Useful Plugins for WordPress'>8 Recommended Useful Plugins for WordPress</a></li>
<li><a href='http://www.fldtrace.com/wordpress/load-javascript-on-specific-pages-in-wordpress' rel='bookmark' title='Permanent Link: How to load Javascript on specific pages in WordPress'>How to load Javascript on specific pages in WordPress</a></li>
<li><a href='http://www.fldtrace.com/wordpress/float-images-in-wordpress-properly' rel='bookmark' title='Permanent Link: Float images in WordPress properly'>Float images in WordPress properly</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h2>The power of if / else statement in WordPress<span id="more-718"></span></h2>
<p>The requests mentioned above, can be implemented with a smart if /else statement solution:</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;!--sidebar conditional navigation sidebar--&gt;
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_page_template<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'page-services.php'</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;!--than include the services specific navigation--&gt;
                <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;side-nav-services.php&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> is_home<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">7</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_single<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_category<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;!--if not, include the blog navigation for blog section--&gt;
                <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;side-nav-blog.php&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span>
        	<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
            	&lt;!--if not anything from above, include the generic page navigation for the rest of the pages--&gt;
                <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;side-nav-pages.php&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>            
            <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>




<h2>Code explained:</h2>
<h3>First statement</h3>
<p>The first piece of code tells us if we have a <a href="http://codex.wordpress.org/Pages#Page_Templates">page template</a> page-services.php, than it should include the navigation for that part. The <b>side-nav-services.php</b> contains:</p>


<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">   <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;side-nav&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;side-nav-services&quot;</span>&gt;</span>
   		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
        	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h3</span>&gt;</span>Services<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h3</span>&gt;</span>
                        <span style="color: #808080; font-style: italic;">&lt;!--the code from below will display sub-pages of services page with the id of 4--&gt;</span>
			<span style="color: #009900;">&lt;?php wp_list_pages<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'child_of=4&amp;title_li&amp;depth=1'</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span>
    	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
&nbsp;
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
                <span style="color: #808080; font-style: italic;">&lt;!--this code will display the popular links, manageable from wordpress backend--&gt;</span>
        	<span style="color: #009900;">&lt;?php get_links<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>




<h3>Second statement</h3>
<p>The second portion of code, includes instead, the blog links from the file <b>side-nav-blog.php</b> for blog index, categories and single page. Here, the sidebar contains:</p>


<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">   <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;side-nav&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;side-nav-blog&quot;</span>&gt;</span>
      		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">h3</span>&gt;</span>Latest Posts<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h3</span>&gt;</span>
        	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&lt;?php bloginfo('url') ;?&gt;</span></span>/health-wisdom&quot;&gt;Health Wisdom Blog<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
				<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
					<span style="color: #009900;">&lt;?php wp_get_archives<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'title_li=&amp;type=postbypost&amp;limit=10'</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span>
                <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>           
            <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
    	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
   		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">h3</span>&gt;</span>Categories<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h3</span>&gt;</span>
        	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&lt;?php bloginfo('url') ;?&gt;</span></span>/health-wisdom&quot;&gt;Health Wisdom Blog<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
				<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
					<span style="color: #009900;">&lt;?php wp_list_categories<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'&amp;title_li='</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span>
                <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>           
            <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
    	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
		<span style="color: #009900;">&lt;?php if <span style="color: #66cc66;">&#40;</span> function_exists<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'wp_tag_cloud'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> : ?&gt;</span>
&nbsp;
&nbsp;
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">h3</span>&gt;</span>Popular Tags<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h3</span>&gt;</span>
            <span style="color: #009900;">&lt;?php wp_tag_cloud<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'smallest=8&amp;largest=22'</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
        <span style="color: #009900;">&lt;?php endif; ?&gt;</span> 
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>




<h3>Third statement</h3>
<p>The last logic, tells that if there is no blog or services section it should load the normal navigation. <b>side-nav-pages.php</b> contains:</p>


<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">   <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;side-nav&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;side-nav-pages&quot;</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
        	<span style="color: #009900;">&lt;?php get_links<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>




<h2>Conclusion</h2>
<p>While the same result could have been accomplished with other method, by creating page templates for each sidebar, that method is more clumsy and the site harder to maintain.</p>
<p>If / else statements, can be of tremendous help in accomplishing tasks with WordPress (or other CMS applications) and can be used for displaying categories in a certain way or output code only in desired areas of the website.</p>
<p>This programming logic, also allows the developer code faster and the websites will be easier to maintain.</p>
 <img src="http://www.fldtrace.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=718" width="1" height="1" style="display: none;" />

<p>Related posts:<ol><li><a href='http://www.fldtrace.com/wordpress/8-recommended-useful-plugins-for-wordpress' rel='bookmark' title='Permanent Link: 8 Recommended Useful Plugins for WordPress'>8 Recommended Useful Plugins for WordPress</a></li>
<li><a href='http://www.fldtrace.com/wordpress/load-javascript-on-specific-pages-in-wordpress' rel='bookmark' title='Permanent Link: How to load Javascript on specific pages in WordPress'>How to load Javascript on specific pages in WordPress</a></li>
<li><a href='http://www.fldtrace.com/wordpress/float-images-in-wordpress-properly' rel='bookmark' title='Permanent Link: Float images in WordPress properly'>Float images in WordPress properly</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.fldtrace.com/wordpress/include-different-sidebar-in-wordpress-depending-on-section/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why web designers should develop using Windows</title>
		<link>http://www.fldtrace.com/freelancing/why-web-designers-should-develop-using-windows</link>
		<comments>http://www.fldtrace.com/freelancing/why-web-designers-should-develop-using-windows#comments</comments>
		<pubDate>Sun, 14 Feb 2010 19:13:18 +0000</pubDate>
		<dc:creator>Lucian</dc:creator>
				<category><![CDATA[freelancing]]></category>

		<guid isPermaLink="false">http://www.fldtrace.com/freelancing/why-web-designers-should-develop-using-windows-7</guid>
		<description><![CDATA[Most of web designers and developers, I know or heard of, are building websites using a MAC PC or laptop.

While it is nothing wrong with that, I am firm adept of Windows platform, though there are advantages or disadvantages of each operating system.

Is true that MACS are sexier, much easier to work with, plus can save time and headaches to developer, but in the end, we build websites for our clients. That's why  their needs should be our focus.

Here are few reasons, why web developers should use Windows OS when we build websites:


Related posts:<ol><li><a href='http://www.fldtrace.com/design/mistakes-printgraphic-designers-do-when-design-websites' rel='bookmark' title='Permanent Link: Mistakes print/graphic designers do when design websites'>Mistakes print/graphic designers do when design websites</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h2>Windows platform is the most used<span id="more-699"></span></h2>
<p>W3schools has published a research page with <a href="http://www.w3schools.com/browsers/browsers_os.asp">Operating system statistics</a> and Windows family counts 90% of the most used operating systems.</p>
<p>As some of you may know, there are some CSS bugs that can be encountered only using a specific OS, even if you use the same browser.</p>
<p>I remember while I was working on a project and I had to setup some images as background, it showed great using Firefox on my Windows but I&#8217;ve been informed that on Firefox for Mac OS X, it was displayed 5px down, enough to ruin the design. If I would have used the MAC I would have tried to make it look right there and possibly ignored the rest of 90% of users, as I couldn&#8217;t know about the problem.</p>

<h2>Using Windows 7, you can run native IE6 and IE7</h2>
<p>Maybe the Windows Vista was a bad OS but those of you who have installed Windows 7, I am sure you were surprised in a good way. At least I am.</p>
<p>While there are some tools for testing websites in IE using <a href="http://www.my-debugbar.com/wiki/IETester/HomePage">IE Tester</a> or <a href="http://spoon.net/browsers/">spoon.net/browsers</a>, there are differences and the big minus is that you cannot install the IE developer toolbar, as you can do on a native IE6 or IE7 (the toolbar is not Firebug, but helps!).</p>
<p>If you have Windows 7, you can run native IE6 and IE7 using XP Mode feature. I found an article that shows you <a href="http://www.sitepoint.com/blogs/2009/11/20/ie6-ie7-ie8-windows-7-home/">how to install a virtual machine and setup XP Mode</a>.</p>

<h2>Viruses are not detected on Macs &#8211; security issue</h2>
<p>Now you may think, it is very good to stay away from viruses and it is for the regular users. However, we developers, are responsible and need to identify potential threats, while having a mac you won&#8217;t be aware of those and the rest of 90% of users might get infected.</p>
<p>I got a job recently, where I had to improve a Joomla website. While the website had no issues, when I tried to log-in in administrator area, my local Bitdefender antivirus, blocked some Trojans.</p>
<p>The Mac users might still have a solution. Chrome seems to identify better infected websites, and won&#8217;t let you access it, so you will know at least that there is a problem.</p>
<p>However, if you try to clean up an infected website, you still need an antivirus to point to the infected files but Antiviruses for Macs detects threats for Macs, not for PC and so, not for majority of users.</p>

<h2>Buying a Windows system is cheaper</h2>
<p>Productivity is important, that&#8217;s why each 3 years or so, I personally, need to change my laptop with a more advanced one, as technology is moving faster and the software demands more resources. </p>
<p>Even if you use a Mac, you still need to upgrade it after a period and they don&#8217;t come cheap.</p>

<h3>Conclusion:</h3>
<p>While the Windows is more vulnerable to viruses, buggier, not that stable as a Mac, I believe the points discussed above, should make you think about making the switch or decide a platform, as a web developer.</p>
<p>Let me know what&#8217;s you opinion regarding building websites on Mac OS X vs Windows.</p> <img src="http://www.fldtrace.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=699" width="1" height="1" style="display: none;" />

<p>Related posts:<ol><li><a href='http://www.fldtrace.com/design/mistakes-printgraphic-designers-do-when-design-websites' rel='bookmark' title='Permanent Link: Mistakes print/graphic designers do when design websites'>Mistakes print/graphic designers do when design websites</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.fldtrace.com/freelancing/why-web-designers-should-develop-using-windows/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BBpress Front Page Text Plugin</title>
		<link>http://www.fldtrace.com/wordpress/bbpress-front-page-text-plugin</link>
		<comments>http://www.fldtrace.com/wordpress/bbpress-front-page-text-plugin#comments</comments>
		<pubDate>Mon, 25 Jan 2010 18:28:35 +0000</pubDate>
		<dc:creator>Lucian</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.fldtrace.com/wordpress/bbpress-front-page-text</guid>
		<description><![CDATA[BBpress Front Page Text for BBpress forum has been released and this post will serve as plug-in's home page. The simple plug-in, adds a back-end option for administrators to add/manage content for forum's front page. While the developers can easily add the text by diving in the back-end, the plug-in allows the the clients to easily update the content without being code savvy. It also helps if you need to update the front page text regularly.


Related posts:<ol><li><a href='http://www.fldtrace.com/wordpress/show-subpages-for-the-current-parent-page-in-wordpress' rel='bookmark' title='Permanent Link: Show subpages only for the current parent page in WordPress'>Show subpages only for the current parent page in WordPress</a></li>
<li><a href='http://www.fldtrace.com/wordpress/8-recommended-useful-plugins-for-wordpress' rel='bookmark' title='Permanent Link: 8 Recommended Useful Plugins for WordPress'>8 Recommended Useful Plugins for WordPress</a></li>
<li><a href='http://www.fldtrace.com/wordpress/how-to-display-parent-page-title-in-wordpress' rel='bookmark' title='Permanent Link: How To Display Parent Page Title in WordPress'>How To Display Parent Page Title in WordPress</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h2>Download BBpress Front Page Plugin<span id="more-681"></span></h2>
<p>You can download the version 1.0 of the plugin <a href="http://www.fldtrace.com/releases/front-page-text.zip">here</a>.</p>
<p>As you may know, the current version of BBpress does not include the WordPress nice functions of formatting text but this release also includes a WYSIWYG editor so you can format the text using headings, paragraphs, etc.</p>

<h2>Installation</h2>
<p>Unzip the the file and add within your bb-plugins folder than go in the bb-admin control panel and activate the plugin.</p>
<p>The <b>Front Page Text</b> tab should appear after the Settings tab. Go inside and add the desired text. </p>
<p>The only thing left to do is to call that text, within your <b>front-page.php</b> in your active theme folder by using the tag:</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;">echo</span> bb_get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'homepage_text'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>



<p>The plug-in is built in mind for home page, but you can add the tag anywhere in your template files, for example the registration page.</p>

<h3>Compatibility</h3>
<p>The plug-in has been tested with the BBpress 0.9 and 1.02 versions and it is built to work with further BBpress releases, unless some radical modifications are added on the way.</p>

<h3>Notes</h3>
<p>The plug-in is free to use and modify. Enjoy!</p>
<p>Let me know if you have any feedback. </p>
 <img src="http://www.fldtrace.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=681" width="1" height="1" style="display: none;" />

<p>Related posts:<ol><li><a href='http://www.fldtrace.com/wordpress/show-subpages-for-the-current-parent-page-in-wordpress' rel='bookmark' title='Permanent Link: Show subpages only for the current parent page in WordPress'>Show subpages only for the current parent page in WordPress</a></li>
<li><a href='http://www.fldtrace.com/wordpress/8-recommended-useful-plugins-for-wordpress' rel='bookmark' title='Permanent Link: 8 Recommended Useful Plugins for WordPress'>8 Recommended Useful Plugins for WordPress</a></li>
<li><a href='http://www.fldtrace.com/wordpress/how-to-display-parent-page-title-in-wordpress' rel='bookmark' title='Permanent Link: How To Display Parent Page Title in WordPress'>How To Display Parent Page Title in WordPress</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.fldtrace.com/wordpress/bbpress-front-page-text-plugin/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to load Javascript on specific pages in WordPress</title>
		<link>http://www.fldtrace.com/wordpress/load-javascript-on-specific-pages-in-wordpress</link>
		<comments>http://www.fldtrace.com/wordpress/load-javascript-on-specific-pages-in-wordpress#comments</comments>
		<pubDate>Wed, 20 Jan 2010 23:44:08 +0000</pubDate>
		<dc:creator>Lucian</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.fldtrace.com/wordpress/load-javascript-just-on-specific-pages-in-wordpress</guid>
		<description><![CDATA[The website speed and responsiveness are very important factors and this aspects should not be neglected if you want to have happy visitors.

There are many areas that should be improved for better website performance as: smart wise written (X)HTML/CSS, optimized images and minimal javascript.

On larger websites, you will have JavaScript, that needs to be loaded just on certain pages or areas from the website, without needing to load it and slow down those.


Related posts:<ol><li><a href='http://www.fldtrace.com/wordpress/float-images-in-wordpress-properly' rel='bookmark' title='Permanent Link: Float images in WordPress properly'>Float images in WordPress properly</a></li>
<li><a href='http://www.fldtrace.com/wordpress/how-to-display-dynamic-menu-in-wordpress' rel='bookmark' title='Permanent Link: How To Display Dynamic Menu Pages In WordPress'>How To Display Dynamic Menu Pages In WordPress</a></li>
<li><a href='http://www.fldtrace.com/wordpress/bbpress-front-page-text-plugin' rel='bookmark' title='Permanent Link: BBpress Front Page Text Plugin'>BBpress Front Page Text Plugin</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h2>Adding the JavaScript in header<span id="more-665"></span></h2>
<p>In this post, I want to show you how to include JavaScript, just on specific pages or areas in WordPress.
First thing you have to do, is to add the JavaScript you want to load in your theme folder of WordPress. To keep everything organized, create a folder called &#8220;Scripts&#8221; or &#8220;Js&#8221;.</p>

<p>Than, open you header.php file from you active theme and instead calling the link as you normally do, paste the following code within the <b>head</b> tag:</p>

<h3>The Code</h3>


<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>is_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'home'</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;!--home page custom JS--&gt;
    &lt;script type='text/javascript' src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_directory'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/Scripts/customJS.js&quot;&gt;&lt;/script&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>




<h3>Code explained</h3>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'home'</span><span style="color: #009900;">&#41;</span></pre></div></div>



<p>That means that if you have permalinks active and a page called home, the JavaScript will load just on that page. </p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;!--</span>home page custom JS<span style="color: #339933;">--&gt;</span></pre></div></div>



<p>This is a simple HTML comment to keep organized or to make the life easier to other developers who might have to work with your code.</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;script type='text/javascript' src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_directory'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/Scripts/customJS.js&quot;&gt;&lt;/script&gt;</pre></div></div>



<p>Basically, this is the link to our JavaScript file that could stay by itself just that will be loaded on all of the pages.</p>


<h3>Variations</h3>

<p>Additionally, you can  have more pages like that inclusive a page id (please replace just this line in the code from above):</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'home'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'contact'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'45'</span><span style="color: #009900;">&#41;</span></pre></div></div>




<p>Or sections as:</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_single<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></pre></div></div>




<p>For more options please refer to <a href="http://codex.wordpress.org/Conditional_Tags">WordPress Conditional Tags</a></p>

<h2>Remove WordPress plugins JavaScript</h2>

<p>This is a tricky one. The websites which use WordPress as CMS, need several plug-ins to achieve the desired functionality. Many of those plug-ins insert JavaScript within the <b>head</b> tag using the wp_head() hook.</p>
<p>What happens if we want to call that JavaScript code of specific plugins, just on certain pages? For example, I have a contact form and I want to load its JavaScript only on contact page or I have a video page and the plugin that embeds the videos should be active only on that page.</p>
<p>WordPress offer us a way to disable JavaScript, also called deregister JavaScript, unfortunately not all of the plug-ins are written properly, so with some of them it will not be possible. </p>
<h3>Code needed</h3>
<p>Using following code in our <b>functions.php</b> file, will disable a plug-in&#8217;s JavaScript except the page you specify:</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_print_scripts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_deregister_javascript'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> my_deregister_javascript<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: #339933;">!</span>is_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Contact'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	wp_deregister_script<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contact-form-7'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>




<p>The only plug-ins you can target, are those which use <b>wp_enqueue_script</b> and you need to find the <b>handle</b> for that specific plugin by browsing it&#8217;s main .php file. </p>
<p>Justin Tadlock on his blog, offers a more in depth <a href="http://justintadlock.com/archives/2009/08/06/how-to-disable-scripts-and-styles">tutorial</a> regarding this matter.</p>

<h2>References</h2>
<p>The order you insert JavaScript is important, especially when you deal with Jquery in WordPress. You might want to check out this article as well:
<a href="http://digwp.com/2009/06/use-google-hosted-javascript-libraries-still-the-right-way/">Use Google-Hosted JavaScript Libraries (…still the Right Way)</a>
</p> <img src="http://www.fldtrace.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=665" width="1" height="1" style="display: none;" />

<p>Related posts:<ol><li><a href='http://www.fldtrace.com/wordpress/float-images-in-wordpress-properly' rel='bookmark' title='Permanent Link: Float images in WordPress properly'>Float images in WordPress properly</a></li>
<li><a href='http://www.fldtrace.com/wordpress/how-to-display-dynamic-menu-in-wordpress' rel='bookmark' title='Permanent Link: How To Display Dynamic Menu Pages In WordPress'>How To Display Dynamic Menu Pages In WordPress</a></li>
<li><a href='http://www.fldtrace.com/wordpress/bbpress-front-page-text-plugin' rel='bookmark' title='Permanent Link: BBpress Front Page Text Plugin'>BBpress Front Page Text Plugin</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.fldtrace.com/wordpress/load-javascript-on-specific-pages-in-wordpress/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Mistakes print/graphic designers do when design websites</title>
		<link>http://www.fldtrace.com/design/mistakes-printgraphic-designers-do-when-design-websites</link>
		<comments>http://www.fldtrace.com/design/mistakes-printgraphic-designers-do-when-design-websites#comments</comments>
		<pubDate>Mon, 30 Nov 2009 00:56:34 +0000</pubDate>
		<dc:creator>Lucian</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Array]]></category>

		<guid isPermaLink="false">http://www.fldtrace.com/?p=481</guid>
		<description><![CDATA[This article is not only meant for print/graphic designers but for the others web designers as well.

Although, I am web designer myself, I found working with a few clients, who already had the website design ready and need to slice into (X)HTML/CSS, which part I love and cannot complain about. These types of designs usually are provided by in house graphic designer, other graphic design freelancer or a web design company.


Related posts:<ol><li><a href='http://www.fldtrace.com/wordpress/how-to-display-dynamic-menu-in-wordpress' rel='bookmark' title='Permanent Link: How To Display Dynamic Menu Pages In WordPress'>How To Display Dynamic Menu Pages In WordPress</a></li>
<li><a href='http://www.fldtrace.com/freelancing/why-web-designers-should-develop-using-windows' rel='bookmark' title='Permanent Link: Why web designers should develop using Windows'>Why web designers should develop using Windows</a></li>
<li><a href='http://www.fldtrace.com/css/better-techniques-for-writing-css-and-markup' rel='bookmark' title='Permanent Link: Better techniques for writing CSS and markup'>Better techniques for writing CSS and markup</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The designs themselves are admirable, however are created by designers, who have little or no experience in real Web design world, or working with (X)HTML/CSS and in some situations, do not have the final implementation in mind.<span id="more-481"></span></p>

<p>While those issues are not critical, I think straighten out some of those, can save time to both parties involved in the project and can also provide better usability and accessibility. Thus far, I have experienced the following:</p>
<h2>No home link in navigation</h2>
<p><img class="alignnone size-full wp-image-530" title="no-home-link2" src="http://www.fldtrace.com/wp-content/uploads/2009/11/no-home-link2.jpg" alt="no-home-link2" width="710" height="100" /></p>

<p>This is a usability issue that I have observed in designs I have received. The logo can still act as a link which takes on first page and a lot of us know about that, but in the same time there are visitors who don’t know that the logo is supposed to take home.</p>

<p>Home button link in navigation is a must have and the visitors are familiar with that in other websites.</p>
<h2>Simple or not footer information</h2>
<p><img class="alignnone size-full wp-image-531" title="no-footer1" src="http://www.fldtrace.com/wp-content/uploads/2009/11/no-footer1.jpg" alt="no-footer1" width="710" height="100" /></p>

<p>Most of the experienced web designers know that the footer is an important area of the website. You can present there a lot of information, which otherwise, you cannot present in other areas. Furthermore, you can repeat here most of the important links of your website which is very good for SEO. You can also present contact information and company address which will help you better rank in Google business listings. Other information you can display there, may be latest blog posts, sitemap, socials, latest tweet pulled from a twitter account, meta information like copyright and year etc.</p>

<p>Again, I had to slice designs with just minimal information or no footer at all! Footer is an important element and users expect it, so you should use it.</p>
<h2>Not using a grid system</h2>
<img class="alignnone size-full wp-image-529" title="no-grid1" src="http://www.fldtrace.com/wp-content/uploads/2009/11/no-grid1.jpg" alt="no-grid1" width="710" height="100" />

<p>Every designer should know about the  <a href="http://en.wikipedia.org/wiki/Golden_ratio">golden ratio</a> which makes a design more esthetic.</p>

<p>While out there are some excellent designs, which are not based on the golden ratio, using it, is a good practice and can save time while designing and developing.</p>

<p>Not once, I had to calculate that left sidebar 268px wide with a 13px margin right and the 569px wide text area. You know what I mean by that.</p>

<p>I use <a href="http://960.gs/">960.gs grid system</a> when I design in Photoshop, and make design process faster while designs look excellent.</p>
<h2>Repeating backgrounds not repeat</h2>
<p><img class="alignnone size-full wp-image-535" title="no-bg-repeat" src="http://www.fldtrace.com/wp-content/uploads/2009/11/no-bg-repeat.jpg" alt="no-bg-repeat" width="710" height="100" /></p>

<p>I had to tutor some designers, how the repeating background should work. If that website edge repeats vertically, will the starting point match the ending point of that edge? What happens when the content box gets very long? Will the background beneath repeat properly?</p>

<p>While some of these tasks are attributed to the one who slice the design, the website should be designed with that in mind.</p>

<p>Most of times I have to use clone stamp tool, one of my best friends in Photoshop, to fix those <em>non </em> repeating backgrounds.
<h2>Provide design in illustrator format instead of Photoshop</h2>
<p><img class="alignnone size-full wp-image-537" title="ilustrator" src="http://www.fldtrace.com/wp-content/uploads/2009/11/ilustrator.jpg" alt="ilustrator" width="710" height="100" /></p>

<p>While some designers are more comfortable using Illustrator rather Photoshop, I consider the websites should be layout in Photoshop. Illustrator can be used for logos and other website illustration elements, thereafter imported in Photoshop, but ultimately, Photoshop should remain the main choice for designing the website. Illustrator is vector creation software while Photoshop is image creation and editing software, while the website, is not vector; it is just a static image needed to be sliced.</p>

<p>If you are better using Illustrator and you slice the layout by yourself, you are welcomed use it. However, most web designers use Photoshop for website design and are familiar with that.</p>
<h2>Layers in Photoshop not organized properly</h2>
<p><img class="alignnone size-full wp-image-538" title="psd-layers" src="http://www.fldtrace.com/wp-content/uploads/2009/11/psd-layers.jpg" alt="psd-layers" width="710" height="100" /></p>

<p>That is another issue I encountered trying to find my way in document. A website has header, content and footer areas. Within header we usually have logo, navigation, search box or related elements. Each one of these elements should get their own folder and should be organized in their appearance order.</p>

<p>The layers should also have the option to be turned on/off, especially the navigation buttons which, eventually, will be used as background.</p>

<p>Text layers should not be rasterized so whenever somebody tries to edit the layer they can copy the text as needed.</p>
<h2>Web safe fonts</h2>
<p><img class="alignnone size-full wp-image-540" title="web-safe" src="http://www.fldtrace.com/wp-content/uploads/2009/11/web-safe.jpg" alt="web-safe" width="710" height="100" /></p>

<p>Print designers are very fond of their chosen fonts and I am sure they would like using it in all website copy. I agree that the font is a very subtle, but important element of design itself, however it is not possible, using traditional methods, include that everywhere.  <a href="http://typekit.com/">Typekit</a> can help in those kind of situations, however not everybody is willing to pay yearly fees or simply the desired font might not be included in the library.</p>

<p>Usually I use <a href="http://www.mikeindustries.com/blog/sifr/">sIFR</a> method for headlines text replacement and images as a background for navigation.</p>

<p>The font for the body still needs to be web safe font like Arial, Helvetica, Georgia etc. That is another point I have to clarify while I work with a designer.</p>
<h2>Not all elements are designed</h2>
<p><img class="alignnone size-full wp-image-541" title="elements-design" src="http://www.fldtrace.com/wp-content/uploads/2009/11/elements-design.jpg" alt="elements-design" width="710" height="100" /></p>

<p>Here I am referring to those list items bullets, headings 2, 3 and 4, block quote if necessary, contact form inputs, which are not provided most of times.</p>

<p>Luckily I can improvise those by myself, however would make everything easier if the original designer would provide those elements designed.</p>
<h3>Which was your experience?</h3>
<p>Which other issues have you encountered while working with somebody else design? Please comment below.</p> <img src="http://www.fldtrace.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=481" width="1" height="1" style="display: none;" />

<p>Related posts:<ol><li><a href='http://www.fldtrace.com/wordpress/how-to-display-dynamic-menu-in-wordpress' rel='bookmark' title='Permanent Link: How To Display Dynamic Menu Pages In WordPress'>How To Display Dynamic Menu Pages In WordPress</a></li>
<li><a href='http://www.fldtrace.com/freelancing/why-web-designers-should-develop-using-windows' rel='bookmark' title='Permanent Link: Why web designers should develop using Windows'>Why web designers should develop using Windows</a></li>
<li><a href='http://www.fldtrace.com/css/better-techniques-for-writing-css-and-markup' rel='bookmark' title='Permanent Link: Better techniques for writing CSS and markup'>Better techniques for writing CSS and markup</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.fldtrace.com/design/mistakes-printgraphic-designers-do-when-design-websites/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How To Display Dynamic Menu Pages In WordPress</title>
		<link>http://www.fldtrace.com/wordpress/how-to-display-dynamic-menu-in-wordpress</link>
		<comments>http://www.fldtrace.com/wordpress/how-to-display-dynamic-menu-in-wordpress#comments</comments>
		<pubDate>Mon, 31 Aug 2009 02:55:50 +0000</pubDate>
		<dc:creator>Lucian</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.fldtrace.com/?p=312</guid>
		<description><![CDATA[I have came across couple methods to display menu pages items in Wordpress including static one recommended by Wordpress, but none of it was suited for my clients needs, since you had to hack the code each time you added a new page.  The method I will show you is absolute dynamic and your client or you, can display pages, subpages and highlight them dynamically.


Related posts:<ol><li><a href='http://www.fldtrace.com/wordpress/load-javascript-on-specific-pages-in-wordpress' rel='bookmark' title='Permanent Link: How to load Javascript on specific pages in WordPress'>How to load Javascript on specific pages in WordPress</a></li>
<li><a href='http://www.fldtrace.com/wordpress/include-different-sidebar-in-wordpress-depending-on-section' rel='bookmark' title='Permanent Link: Include different sidebar in WordPress, depending on the section you are'>Include different sidebar in WordPress, depending on the section you are</a></li>
<li><a href='http://www.fldtrace.com/wordpress/how-to-display-parent-page-title-in-wordpress' rel='bookmark' title='Permanent Link: How To Display Parent Page Title in WordPress'>How To Display Parent Page Title in WordPress</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h2>Non Productive Method (WordPress Codex Solution)<span id="more-312"></span></h2>

<p>Please note that this solution is non productive whenever you want to have normal text as menu links. In case you want to have a navigation using images, this would be the solution for you. The main navigation from <a href="http://malorestaurant.com">this website</a> it is built using a background image and switch its position based on the ID of the menu item, with the help of CSS. This type of navigation can be done just using WordPress solution (next code), as we can&#8217;t assign ID&#8217;s dynamically, using WordPress Dynamic Menu Page Method, described later in tutorial.
</p>


<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;home-item&quot;</span> &lt;?php if <span style="color: #66cc66;">&#40;</span>is_page<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'home'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> echo <span style="color: #ff0000;">' class=&quot;current&quot;'</span>; <span style="color: #66cc66;">&#125;</span> ?&gt;</span>&gt; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&lt;?php bloginfo('url');?&gt;</span></span>&quot; class=&quot;current&quot;&gt;<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span>&gt;</span>Home<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;services-item&quot;</span> &lt;?php if <span style="color: #66cc66;">&#40;</span> is_page<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'services'</span><span style="color: #66cc66;">&#41;</span> || is_page<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'subpage1'</span><span style="color: #66cc66;">&#41;</span> || is_page<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'subpage2'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> echo <span style="color: #ff0000;">' class=&quot;current&quot;'</span>; <span style="color: #66cc66;">&#125;</span> ?&gt;</span>&gt;<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;services&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">span</span>&gt;</span>Services<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;services/subpage1&quot;</span>&gt;</span>Subpage 1<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;services/subpage2&quot;</span>&gt;</span>Subpage 2<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;contact-item&quot;</span> &lt;?php if <span style="color: #66cc66;">&#40;</span>is_page<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'contact'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> echo <span style="color: #ff0000;">' class=&quot;current&quot;'</span>; <span style="color: #66cc66;">&#125;</span> ?&gt;</span>&gt; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;contact&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;current&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">span</span>&gt;</span>Contact<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span></pre></div></div>




<p>The first list item, Home, has a conditional to check if is home page it should set a class of &#8220;current&#8221; so you can display the current page in a different way, so the usability of the site will be increased.</p>
<p>The second list item has two sub pages, that using CSS, will show up as drop down. If the Services page will be active, WordPress will automatically assign a class of &#8220;current&#8221; to its list item.</p>
<p>In this method the &#8220;span&#8221; tag will help us to hide the text so we can view just the background image.</p>

<p>The example contains just 3 list items, but if we want to have more, it can can become very  hard at some point, to maintain the menu. Plus, if you want to give your client the control over navigation this is not a viable solution.</p>

<h2>WordPress Dynamic Menu Page Method</h2>

<p>You can  see a <a href="http://www.kaiac.ro/">demo</a> of this method, within a website I have developed. All of the menu there, is generated dynamically by the code described below.</p>
<p>You can see in that demo, that we can still assign background images and have in the same time real text. The text is wrapped with a &#8220;span tag&#8221; so we can use a CSS method called <a href="http://www.alistapart.com/articles/slidingdoors/">sliding doors</a> to set images as background for this menu-items.</p>

<h3>The dynamic solution would be:</h3>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;ul&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_list_pages<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&amp;title_li=&amp;link_before=&lt;span&gt;&amp;link_after=&lt;/span&gt;&amp;depth=2'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/ul&gt;</pre></div></div>




<h3>The Code Explained</h3>
<p>
This piece of code is a WordPress tag that calls the pages and set their titles a names. Also we want to display any sub page as a dropdown with the help of CSS so we specify a depth of 2. </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> wp_list_pages<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&amp;title_li&amp;depth=2'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>



<p>If we want to display a higher number of sub pages, we just increase the number or remove &#8220;&#038;depth=2&#8243; so will display unlimited sub pages.
</p>

<p>Because we want to set images as background for the menu items, we have to add a span tag:</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> wp_list_pages<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&amp;title_li=&amp;link_before=&lt;span&gt;&amp;link_after=&lt;/span&gt;&amp;depth=2'</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>Html Result:</h3>
<p>Now we have a totally dynamic menu and submenu, that will display as HTML like so:</p>


<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;current&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;home&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">span</span>&gt;</span>Home<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;services&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">span</span>&gt;</span>Services<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;subpage-1&quot;</span>&gt;</span>Subpage 1<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;subpage2&quot;</span>&gt;</span>Subpage 2<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span></pre></div></div>




<h3>The CSS</h3>
<p>Now we have the HTML dynamic generated, but we still need to customize it with CSS. We will do this in a separate lesson, where I will show you how to set up background images for menu items, as a <a href="http://www.apple.com/">Apple menu way</a>.</p>

<h3>WordPress Menu Page Highlighting With CSS</h3>
<p>Now if you take a look the source code, you will see that WordPress outputs a &#8220;current_page_item&#8221; class to the corresponding li tag of the page where you are. Now is very easy, with the help of CSS, to display in bold, the current page link:</p> 

<h4>Highlight the parent page</h4>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">li<span style="color: #6666ff;">.current_page_item</span> a <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">&#125;</span></pre></div></div>




<h4>Highlight parent&#8217;s child page</h4>
<p>What if you want to have the parent page bold, while you are on one if its subpage? WordPress comes in help again, outputting dynamically, a special class &#8220;current_page_ancestor&#8221;, so our code will look like that in this case: </p>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">li<span style="color: #6666ff;">.current_page_ancestor</span> a <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">&#125;</span></pre></div></div>




<p>That was it. I assumed in this article, that you already have basic CSS knowledge and you are aware of CSS specificity.</p> 




<h2>Some Helpful Plugins:</h2>
<h3>Page Exclusion</h3>
<p>If you need to have some pages excluded from navigation you need the <a href="http://wordpress.org/extend/plugins/exclude-pages/">exclude pages</a> plugin.</p>

<h3>My Page Order</h3>
<p>A really useful plugin is <a href="http://wordpress.org/extend/plugins/my-page-order/">my page order</a> plugin, which will allow you to order the pages in your menus.</p>

<h3>Page Tree Overview</h3>
<p>If it happens to work on a website with a lot of pages <a href="http://wordpress.org/extend/plugins/page-tree/">wordpress page tree</a> will give you an overview of those and you can reach a specific page really quick in order to edit it.</p>

<h2>Resources:</h2>
<p>WordPress non productive method: <a href="http://codex.wordpress.org/Dynamic_Menu_Highlighting">WordPress Dynamic Menu Highlighting</a>.</p>
<p>Here you can find a great resource for WordPress dynamic page menu: <a href="http://digwp.com/2009/07/delicious-recipes-wordpress-page-menus/">Delicious Recipes WordPress Page Menus</a>.</p>
 <img src="http://www.fldtrace.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=312" width="1" height="1" style="display: none;" />

<p>Related posts:<ol><li><a href='http://www.fldtrace.com/wordpress/load-javascript-on-specific-pages-in-wordpress' rel='bookmark' title='Permanent Link: How to load Javascript on specific pages in WordPress'>How to load Javascript on specific pages in WordPress</a></li>
<li><a href='http://www.fldtrace.com/wordpress/include-different-sidebar-in-wordpress-depending-on-section' rel='bookmark' title='Permanent Link: Include different sidebar in WordPress, depending on the section you are'>Include different sidebar in WordPress, depending on the section you are</a></li>
<li><a href='http://www.fldtrace.com/wordpress/how-to-display-parent-page-title-in-wordpress' rel='bookmark' title='Permanent Link: How To Display Parent Page Title in WordPress'>How To Display Parent Page Title in WordPress</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.fldtrace.com/wordpress/how-to-display-dynamic-menu-in-wordpress/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
