<?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>New2WP &#187; Demos</title>
	<atom:link href="http://new2wp.com/levels/demos/feed/" rel="self" type="application/rss+xml" />
	<link>http://new2wp.com</link>
	<description>Wordpress Tips for Noobs, Rookies and Pros</description>
	<lastBuildDate>Mon, 29 Aug 2011 13:00:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1-RC2</generator>
		<item>
		<title>Create jQuery Tabs For WordPress Login-Register-Password Reset Forms</title>
		<link>http://new2wp.com/pro/jquery-tabbed-login-register-forms/</link>
		<comments>http://new2wp.com/pro/jquery-tabbed-login-register-forms/#comments</comments>
		<pubDate>Sat, 22 May 2010 13:10:54 +0000</pubDate>
		<dc:creator>Jared</dc:creator>
				<category><![CDATA[Demos]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Pro]]></category>
		<category><![CDATA[Forms]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Login]]></category>
		<category><![CDATA[Members]]></category>
		<category><![CDATA[Tabs]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://new2wp.com/?p=929</guid>
		<description><![CDATA[You want to learn how to make a custom login and register form for your Wordpress site right? Maybe you want to utilize the password reset form while your at it. Perhaps, you may want to set up all 3 of these forms in a way that isn't confusing to people, or in a way that takes up much space on the page. Well, this tutorial will show you how to do all of this quickly and easily. It's simple.]]></description>
			<content:encoded><![CDATA[<h2>This is the Ultimate Custom Login/Register Form Tutorial</h2>
<p>Let's do away with the plain old, not very cool, default WordPress login/register form page for once, what do you say? I'm going to show you how to change the way you login to your site, and the way others join and login to your site too.</p>
<p>Okay, so you may be thinking what's so great about this tutorial compared to all the other one's posted on the internet. I've seen this a million times, and the all end the same, blah blah blah. </p>
<p>I can pretty much guarantee that there is nothing quite like this posted online, at least not available for free. You may be able to find a similar tut on the Tuts+ network, if you have a premium membership, which is great and all, but how many people actually do. Trust me, this is not like any other tutorial you may have "seen" before. There isn't anything as complete, or useful, or just plain awesome. I know because I have scoured the internet in search of how to create this when I was trying to first make it myself. It's just not out there, until now!</p>
<h2>What you will learn from this tutorial</h2>
<p><strong>How to:</strong></p>
<p><img src="http://new2wp.com/wp-content/uploads/2010/02/wordpress_login.png" alt="Wordpress login logo" title="Wordpress login logo" width="200" height="200" class="alignright size-full wp-image-432" /></p>
<ul>
<li>create a sidebar jQuery UI Tabs widget</li>
<li>create a custom form to show under each tab
<ul>
<li>a WordPress 3.0 Login form</li>
<li>a custom register form</li>
<li>a custom password reset form</li>
</ul>
</li>
<li>check if the visitor is logged in</li>
<li>change the content of the tabs if user is logged in</li>
<li>finally love yourself for knowing how to do this.</li>
</ul>
<h2>What you will need:</h2>
<p>You will need to have some understanding of <a href="http://www.w3schools.com/html5/html5_reference.asp">HTML5</a>, <a href="http://www.w3schools.com/css/default.asp">CSS</a> and <a href="http://jquery.com">jQuery</a> or <a href="http://jqueryui.com">jQueryUI</a>, though it's not required, but <a href="#add" target="_blank"><img src="http://new2wp.com/wp-content/uploads/2010/05/crazy-google-interview-questions1.jpg" alt="Google" title="Google" width="154" height="250" class="alignleft size-full wp-image-952" /></a> it does help. You will also need to either have a self-hosted copy of <a href="http://jquery.com">jQuery</a> and/or <a href="http://jqueryui.com">jQuery UI</a> on your website, if you choose to not use the <a href="http://code.google.com/apis/ajaxlibs/" target="_blank">Google CDN</a> version of these, which I will be using here. If you don't know why I am using the Google hosted copies, then you need to read up on the great advantages of linking to a CDN hosted script. </p>
<p>Basically, CDN hosted files are faster and stuff etc. etc. It's cached on most anyone's computer who has access the internet sometime since the dawn of the modern world and the invention of the internet. Since 90% of sites out there link to a CDN copy of jQuery already, it's a pretty good chance most visitors to your site have the scripts saved already in the cache. Anyways, let's get going shall we.</p>
<h2>1: The HTML5 Tabs Markup</h2>
<p>I'm going to start off slow and show you how I would write the HTML for the jQuery tabs, using the new HTML5 format. You will notice that instead of the <span id="fixed">&lt;div&gt;</span> tag which you may be used to, I am using the new <span id="fixed">&lt;nav&gt;</span> which is a more <a href="http://kateray.net/film/">semantic</a> way of referring to a part of your site that is considered a form of navigation.</p>
<p>What I have below is how you would write it if you wanted to have some unordered lists within your tabs for example. We will be removing these lists later when we create the forms that will go in place of them. But you should keep a copy of this just as a sample of code, in the case that even later in this tutorial, you may want to show list items, for when the user is logged in and there is no need to show the login/register forms.</p>
<p><strong>The HTML5 Tab Markup</strong></p>
<pre class="brush: php; title: ; notranslate">

&lt;div id=&quot;tabs&quot;&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;a href=&quot;#tabs-1&quot;&gt;First Tab&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#tabs-2&quot;&gt;Second Tab&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#tabs-3&quot;&gt;Third Tab&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;

	&lt;nav id=&quot;tabs-1&quot;&gt;
		&lt;ul&gt;
			&lt;li&gt;This is the first tab&lt;/li&gt;
			&lt;li&gt;This is the first tab&lt;/li&gt;
			&lt;li&gt;This is the first tab&lt;/li&gt;
			&lt;li&gt;This is the first tab&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/nav&gt;
	&lt;nav id=&quot;tabs-2&quot;&gt;
		&lt;ul&gt;
			&lt;li&gt;Second tab this is&lt;/li&gt;
			&lt;li&gt;Second tab this is&lt;/li&gt;
			&lt;li&gt;Second tab this is&lt;/li&gt;
			&lt;li&gt;Second tab this is&lt;/li&gt;
			&lt;li&gt;Second tab this is&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/nav&gt;
	&lt;nav id=&quot;tabs-3&quot;&gt;
		&lt;ul&gt;
			&lt;li&gt;Tab three here buddy!&lt;/li&gt;
			&lt;li&gt;Tab three here buddy!&lt;/li&gt;
			&lt;li&gt;Tab three here buddy!&lt;/li&gt;
			&lt;li&gt;Tab three here buddy!&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/nav&gt;
&lt;/div&gt;&lt;!-- // Tabs --&gt;
</pre>
<p>You may have noticed that the first unordered list was not preceded by a <span id="fixed">&lt;nav&gt;</span> element, and this is because this just happens to be how I wrote it here. You could choose to do that if you want, I just kept the tabs and the actual list items separate, so I know that the tabs aren't a navigable list of items, which link to other pages, just other lists. </p>
<p>They are a sort of navigation, just not what I would consider a navigation menu, personally. Also, you might have noticed that the first unordered list elements link to the <span id="fixed">#tabs-<em>tabnumber</em></span>. This is so that, 1. the tabs will match and show the correct tab to which you click on to see the content of, and 2. so that if the user has JavaScript disabled they will still be able to access the content of the tabs because of these anchors. They won't have the cool switcheroo like you would with JavaScript, but you can still see what's there and use it at least. Good practice for keeping your site <a href="http://new2wp.com/pro/part-3-making-a-dynamic-wordpress-jquery-featured-post-slider-tutorial-finale/">progressively enhanced</a>.</p>
<h2>2: Styling The Tabs With CSS</h2>
<p>The great thing about using jQuery UI to create the tabs is that it does all the styling for you, Woohoo! If you went the route of <a href="http://jqueryui.com/download">downloading jQuery UI</a> which by the way can be customized to your needs, to host the files on your website yourself, then you also got the CSS Stylesheet that came with it in the zip file. That CSS file contains all the styles you need for the tabs to work as you want them to, ... tabs. </p>
<p>You can easily customize the styling as far as color and general appearance goes simply by defining a class which you can apply to the <span id="fixed">&lt;div id="tabs"&gt;</span> or just use the <span id="fixed">#tabs</span> ID attribute as your CSS selector, and apply your styling to it with that. </p>
<p>Although, with jQuery UI, there is the Theme Roller, which you can use any of the already created/<em>rolled</em> themes, or <a href="http://jqueryui.com/themeroller" target="_blank">roll your own theme</a> right on the site. It's really neat, and you should at least try it out. I didn't give it as much credit before as I should have long ago. Then I tried it, and wow... I said, now that's fresh. <a href="http://jqueryui.com/themeroller/?ffDefault=Helvetica,%20Arial,%20sans-serif&#038;fwDefault=normal&#038;fsDefault=1.2em&#038;cornerRadius=2px&#038;bgColorHeader=222222&#038;bgTextureHeader=01_flat.png&#038;bgImgOpacityHeader=50&#038;borderColorHeader=555555&#038;fcHeader=ffffff&#038;iconColorHeader=ffffff&#038;bgColorContent=111111&#038;bgTextureContent=01_flat.png&#038;bgImgOpacityContent=16&#038;borderColorContent=404040&#038;fcContent=eeeeee&#038;iconColorContent=bbbbbb&#038;bgColorDefault=1888f8&#038;bgTextureDefault=03_highlight_soft.png&#038;bgImgOpacityDefault=60&#038;borderColorDefault=111111&#038;fcDefault=d2e8fe&#038;iconColorDefault=000000&#038;bgColorHover=53a5f9&#038;bgTextureHover=06_inset_hard.png&#038;bgImgOpacityHover=60&#038;borderColorHover=111111&#038;fcHover=191919&#038;iconColorHover=000000&#038;bgColorActive=7bcc02&#038;bgTextureActive=05_inset_soft.png&#038;bgImgOpacityActive=50&#038;borderColorActive=111111&#038;fcActive=000000&#038;iconColorActive=000000&#038;bgColorHighlight=f5410f&#038;bgTextureHighlight=01_flat.png&#038;bgImgOpacityHighlight=55&#038;borderColorHighlight=ffcead&#038;fcHighlight=ffffff&#038;iconColorHighlight=f5410f&#038;bgColorError=ffd6d6&#038;bgTextureError=07_diagonals_medium.png&#038;bgImgOpacityError=30&#038;borderColorError=cd0a0a&#038;fcError=cd0a0a&#038;iconColorError=930b0b&#038;bgColorOverlay=191919&#038;bgTextureOverlay=01_flat.png&#038;bgImgOpacityOverlay=50&#038;opacityOverlay=20&#038;bgColorShadow=333333&#038;bgTextureShadow=01_flat.png&#038;bgImgOpacityShadow=0&#038;opacityShadow=100&#038;thicknessShadow=15px&#038;offsetTopShadow=-15px&#038;offsetLeftShadow=-15px&#038;cornerRadiusShadow=100px" target="_blank">Check out the theme I created</a>, which you can use it if you want.</p>
<p>Now, if you chose to use a CDN hosted copy of jQuery UI not to worry, you can easily en-queue the script that WordPress comes pre-packaged with out of the box. Whichever way you decided to use, here's how you can link to the CSS Stylesheet file you need for styling up your tabs.</p>
<h3>En-queue the Stylesheet in functions.php file:</h3>
<p>You need to link or en-queue the jQuery UI Styleseet, depending on whether you're using the jQuery UI download pack or the Google CDN copy.<br />
(<small><strong>Note</strong>: If you just upload the jQueryUI.js file from the download, you will need to do the second option here to ensure that the Stylesheet is linked.</small>)</p>
<p><strong>Linking to the Stylesheet directly:</strong></p>
<pre class="brush: php; title: ; notranslate">

/*
 * Link to the CSS source file in your &lt;head&gt; of your site.
 */
function loadStyles() {
	echo '&lt;link href=&quot;'. bloginfo('template_directory') .'/css/jquery-ui-1.8.1.custom.css&quot; /&gt;';
}
add_action('wp_head', 'loadStyles');

/*
 * You can add the javascript file to the footer
 * With this too if you want.
 */
function loadScripts() {
	echo '&lt;script src=&quot;'. bloginfo('template_directory') .'/js/jquery-1.4.2.min.js&quot;&gt;&lt;/script&gt;'; // needed if jQuery isnt loaded
	echo '&lt;script src=&quot;'. bloginfo('template_directory') .'/js/jquery-ui-1.8.1.custom.min.js&quot;&gt;&lt;/script&gt;';
}
add_action('wp_foot', 'loadScripts');
</pre>
<p><strong>Link to the scripts on the Google Content Distribution Network by doing the following instead:</strong></p>
<pre class="brush: php; title: ; notranslate">

/*
 * OR DO THIS if you want to use the Google
 * CDN Hosted scripts
 */
function loadScripts() {
	echo '&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&gt;';
	echo '&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js&quot;&gt;&lt;/script&gt;';
}
add_action('wp_foot', 'loadScripts');
</pre>
<p><strong>En-queue the jQuery UI CSS Stylesheet included in WordPress:</strong></p>
<p>Another way you can choose to load the Stylesheet, jQuery, or jQuery UI is by using the WordPress <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_style"><span id="fixed">wp_enqueue_style()</span></a> and <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script"><span id="fixed">wp_enqueue_script()</span></a> functions. </p>
<p>Here you will find a list of <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_scripts_included_with_WordPress">all the scripts WordPress comes bundled with</a> by default should you be interested to use them in your site for anything else. You would use the same word for en-queuing the style of a particular script too for most all of them if there is a Stylesheet included for any other one you may want to use.</p>
<pre class="brush: php; title: ; notranslate">

function loadStyles() {
	wp_enqueue_styles( 'jqueryui' );
}
add_action('wp_head', 'loadStyles');

/*
 * Embed the jQuery UI javascript file in your
 * Footer using this if you choose to
 */
function loadScripts() {
	wp_enqueue_script( 'jquery' ); // You only need to add this if you do not already have jQuery embedded
	wp_enqueue_script( 'jqueryui' );
}
add_action('wp_foot', 'loadScripts')
</pre>
<p>Do keep in mind that many WordPress plugins, and even many themes do already load jQuery, most commonly anyways, though I have seen plugins embed other scripts and Stylesheets for them. Before you add the jQuery script (as well as jQueryUI script), I would highly recommend you view the source code of your site to see if you already have these loaded. Just right click on the page when viewing the site, and go to "view page source" in Firefox, or in IE it's just "view source". Check to see whether <strong>jQuery.js</strong> is in the source code either in the <span id="fixed">&lt;head&gt;</span> or near the bottom of the page source code within the <span id="fixed">&lt;footer&gt;</span> of the site. More than likely it already is at least once, if not more. Removing them all and leaving just one is a tutorial for another day though.</p>
<h2>3: Initializing the Tabs For Takeoff</h2>
<p>So now that we have the scripts and the styles and the HTML for the tabs all set up, lets test that they at least work before we start putting content in. To do this though, we need to still add one little bit of code which will initialize the tabs. Think of it like this, we set up all the pieces which make up a go kart (or tabs in this case), now we just need to put the key in and turn it on (random analogy I know, but it works right?).</p>
<p>To turn on our tabs you will need to add this line of code, AFTER the jQuery and jQuery UI scripts are loaded. If you have your own <em>custom.js</em> file for things like this, you could put it in there. If not, the way I would do it for now is to open your footer.php, find <span id="fixed"><?php wp_foot(); ?></span>, and put it below that. This ensures it will run after the scripts we embedded using the above functions are loaded.</p>
<pre class="brush: php; title: ; notranslate">

&lt;script type=&quot;text/javascript&quot;&gt;
$(function() {
	$('#tabs').tabs(); // initialize the tabs
});
&lt;/script&gt;
</pre>
<h2>4: Testing The Tabs To Tickle Them Pink</h2>
<p>Now that you have this set up, try testing it out by dropping the first chunk of HTML5 code I gave you into your sidebar.php file, and see if these babies work! Make sure everything is doing dandy before you move onto the rest, and if there happens to be any issues, now would be the best time to resolve them before things start to get more complex. TRUST ME!!! I learned this the hard way, repeatedly, far more than I would've liked to that's for sure.</p>
<h2>5: Getting Down And Dirty With The Forms</h2>
<p>To start this part off, I'd like to point out that this tutorial assumes that you are currently using <a href="http://new2wp.com/rookie/codes-snippets-for-wordpress-3-0-new-features/">WordPress 3.0</a>. If you are not, then you will need to create your own custom login form. I am going to be using the all-new WordPress 3.0 <span id="fixed">wp_login_form()</span> function, which is a great addition to the new version of WordPress, only thing is they didn't make a function for the other forms. For anyone still using WP 2.9.x or earlier, I will show you a quick way to make a login form at the end of this tutorial. (I'm a softy, what can I say)</p>
<p><strong>First thing we need to do is</strong></p>
<p>Check if the user is already logged in! To do that, we start by writing the following:</p>
<pre class="brush: php; title: ; notranslate">

&lt;?php
/*
 * If user not logged in display forms
*/
if (!is_user_logged_in()) :
?&gt;
</pre>
<p>If the user is already logged in, we can then show them a totally different set of tabs and tabbed content. This is a great way to customize your site even more for your members, and to show them different content since they are a member of your awesomely coolio site of hottness!</p>
<h2>6: Next on the list is the tabs HTML</h2>
<p>Nothing new here from what I showed you in the beginning, except that the list items now say <strong>Login</strong>, <strong>Register</strong>, and <strong>Lost Password</strong>. This is a self-explanatory I think, I would hope so at least.</p>
<pre class="brush: php; title: ; notranslate">

&lt;div id=&quot;tabs&quot;&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;a href=&quot;#tabs-1&quot;&gt;Login&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#tabs-2&quot;&gt;Register&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#tabs-3&quot;&gt;Lost Password&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
</pre>
<h2>7: Now for the first tab, the Login Form</h2>
<p>This is the easiest tab of the three. All you have to do is put <span id="fixed">&lt;?php wp_login_form(); ?&gt;</span> in the div for the first tab. Must simpler than the other two as you will see next.</p>
<p><a href="http://new2wp.com/pro/jquery-tabbed-login-register-forms/attachment/login/" rel="attachment wp-att-935"><img src="http://new2wp.com/wp-content/uploads/2010/05/login.png" alt="login" title="login" width="400" height="200" class="aligncenter size-full wp-image-935" /></a></p>
<pre class="brush: php; title: ; notranslate">

	&lt;div id=&quot;tabs-1&quot;&gt;&lt;!-- Login Form --&gt;
		&lt;?php wp_login_form(); ?&gt;
	&lt;/div&gt;
</pre>
<h2>8: Custom Coding The Register Form</h2>
<p>That last part will seem like a breeze compared to this one. Here we create the register form and throw in a couple of PHP functions you may not have seen before, and add the content of the second tab on our list.</p>
<p><a href="http://new2wp.com/pro/jquery-tabbed-login-register-forms/attachment/reg1/" rel="attachment wp-att-934"><img src="http://new2wp.com/wp-content/uploads/2010/05/reg1.png" alt="register" title="register" width="400" height="250" class="aligncenter size-full wp-image-934" /></a></p>
<pre class="brush: php; title: ; notranslate">

	&lt;div id=&quot;tabs-2&quot;&gt;&lt;!-- Register Form --&gt;
		&lt;form method=&quot;post&quot; action=&quot;&lt;?php echo site_url('wp-login.php?action=register', 'login_post') ?&gt;&quot; id=&quot;registerform&quot; name=&quot;registerform&quot;&gt;
			&lt;p&gt;
				&lt;label&gt;Username&lt;br /&gt;
				&lt;input type=&quot;text&quot; tabindex=&quot;10&quot; size=&quot;20&quot; value=&quot;&quot; class=&quot;input&quot; id=&quot;user_login&quot; name=&quot;user_login&quot; /&gt;
				&lt;/label&gt;
			&lt;/p&gt;
			&lt;p&gt;
				&lt;label&gt;E-mail&lt;br /&gt;
				&lt;input type=&quot;text&quot; tabindex=&quot;20&quot; size=&quot;25&quot; value=&quot;&quot; class=&quot;input&quot; id=&quot;user_email&quot; name=&quot;user_email&quot; /&gt;
				&lt;/label&gt;
			&lt;/p&gt;
			&lt;p id=&quot;reg_passmail&quot;&gt;A password will be e-mailed to you.&lt;/p&gt;
			&lt;br class=&quot;clear&quot;&gt;
			&lt;p class=&quot;submit&quot;&gt;
				&lt;?php do_action('login_form', 'register'); ?&gt;
				&lt;input type=&quot;submit&quot; tabindex=&quot;100&quot; value=&quot;Register&quot; class=&quot;button-primary&quot; id=&quot;wp-submit&quot; name=&quot;wp-submit&quot;											 /&gt;
				&lt;input type=&quot;hidden&quot; name=&quot;redirect_to&quot; value=&quot;/&quot; /&gt;
				&lt;input type=&quot;hidden&quot; name=&quot;cookie&quot; value=&quot;1&quot; /&gt;
			&lt;/p&gt;
		&lt;/form&gt;
	&lt;/div&gt;
</pre>
<p>Lets review the above code. Nothing special as far as HTML forms go right? Just a basic HTML form, nothing you can't handle, or haven't seen in your web site making career I hope (if this part is news to you then you may want to check out the W3 for some <a href="http://www.w3schools.com/html/default.asp">beginners HTML tutorials</a>). As for the new stuff the part <span id="fixed">&lt;?php site_url('wp-login.php?action=register', 'login_post'); ?&gt;</span> is making use of the new WordPress 3.0 <a href="http://codex.wordpress.org/Template_Tags/site_url"><span id="fixed">site_url()</span></a> function which is a replacement of the <span id="fixed">get_option('site_url')</span> function in previous versions of WordPress. Here we just add in the URL path of the register form along with scheme of login_post to give the site URL some context. Neither of these arguments are required by default, but in this case, they are. You could just write it like this <span id="fixed">&lt;?php site_url(); ?&gt;/wp-login.php?action=register</span> but that's not as fun is it? </p>
<p>One thing I am not quite sure of though think you may want to leave as is, is whether the form element ID's and name attributes as I have here are required to use these or if you can assign your own names. I just assume keeping the default register form attributes the same, so to keep it from potentially not working (because these work as is I know), and for consistency sake.</p>
<p><a href="http://tweeaks.com/design/attack-of-deliciously-colorful-code-caused-me-to-explode/" rel="bookmark"><img src="http://new2wp.com/wp-content/uploads/2010/05/chicken-little-sky-falling.jpg" alt="chicken" title="chicken-little-sky-falling" width="200" height="246" class="alignright size-medium wp-image-958" /></a>The other strange and unusual part of the register form code is the <span id="fixed">&lt;?php do_action('login_form', 'register'); ?&gt;</span>. This is the meatballs of the entire form. With out this Chicken Little would be quivering in his little chicken.... coup? Because the sky would be falling. </p>
<p>If you want the form to actually do something useful upon being submitted, then it needs to run this function. It tells WordPress that you want to register a new user account, as well as, the sending out of the confirmation email with the crazy randomly auto-generated password you receive when joined a WordPress site. If you have a firm grasp on that we can move on...</p>
<h2>9: Anyone Here Lose A Password?</h2>
<p>This is a form that is many times neglected I think, but just as important to keeping the members of your site which have already registered. I mean, I personally register an account on at LEAST one new site A DAY!! And out of all the sites which I am a registered member of and visit randomly choose to login to on any given day, I have to reset my password on average, TWICE A DAY on 2 different sites, almost without fail. For every site I sign up on each day, I have to reset my password on two other sites which I have forgotten the password for since last visiting it. It's quite annoying, but what the hell can I really do about it at this point?</p>
<p>It's not that unsurprising is it? It seems that every site on the internet now requires you to have an account, and not nearly enough use the <a href="http://www.facebook.com/advertising/?connect">Facebook Connect</a>, <a href="http://www.google.com/friendconnect">Google Friend Connect</a> or some other equivalent API available from various sites. So if you want to keep your members as part of your site, you better damn well make it easy for them to reset their passwords should they forget it amidst the library of passwords we all now must keep cataloged. The less steps they have to take to log back into your site, the more likely they even will at all. </p>
<h2>10: Let's make a password reset form</h2>
<p><a href="http://new2wp.com/pro/jquery-tabbed-login-register-forms/attachment/lostpass/" rel="attachment wp-att-936"><img src="http://new2wp.com/wp-content/uploads/2010/05/lostpass.png" alt="lost password" title="lost password" width="400" height="154" class="aligncenter size-full wp-image-936" /></a></p>
<pre class="brush: php; title: ; notranslate">

	&lt;div id=&quot;tabs-3&quot;&gt;&lt;!-- Lost Password Form --&gt;
		&lt;form method=&quot;post&quot; action=&quot;&lt;?php echo site_url('wp-login.php?action=lostpassword', 'login_post') ?&gt;&quot; id=&quot;lostpasswordform&quot; name=&quot;lostpasswordform&quot;&gt;
			&lt;p&gt;
				&lt;label&gt;Username or E-mail:&lt;br /&gt;
				&lt;input type=&quot;text&quot; tabindex=&quot;10&quot; size=&quot;20&quot; value=&quot;&quot; class=&quot;input&quot; id=&quot;user_login&quot; name=&quot;user_login&quot; /&gt;
				&lt;/label&gt;
			&lt;/p&gt;
			&lt;p class=&quot;submit&quot;&gt;
				&lt;?php do_action('login_form', 'resetpass'); ?&gt;
				&lt;input type=&quot;submit&quot; tabindex=&quot;100&quot; value=&quot;Get New Password&quot; class=&quot;button-primary&quot; id=&quot;wp-submit&quot; name=&quot;wp-submit&quot; /&gt;
				&lt;input type=&quot;hidden&quot; name=&quot;redirect_to&quot; value=&quot;/&quot; /&gt;
				&lt;input type=&quot;hidden&quot; name=&quot;cookie&quot; value=&quot;1&quot; /&gt;
			&lt;/p&gt;
		&lt;/form&gt;
	&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>That wasn't so bad now was it? This isn't all that dis-similar from the register form either. You already know about the <span id="fixed">site_url()</span> function. The only difference here is it's pointing to the URL <em>wp-login.php?action=lostpassword</em> instead of <em>action=register</em>. Also, the <strong>meatballs</strong> as I called it earlier, (the <span id="fixed">do_action()</span> function) is just doing <span id="fixed">&lt;?php do_action('login_form', 'resetpass'); ?&gt;</span>. EUREKA!!!! </p>
<p>That's what I said when I figured this out for this and the register form. It just all of a sudden came to me one day, and I was finally able to make my forms work, and then in-turn, write this amazing tutorial for you. This will send the user a password reset link, which they can click to have a new auto-generated password emailed to them so they can login to their account, and set their password to something a little more memorable.</p>
<h2>11: Finishing Up - Or Are We...?</h2>
<p>We could just end this here and close out the <span id="fixed">if(user is logged in){ or not }</span> statement that started before making the tabs, and that's fine if you've had enough and can't take it any longer. I am not easy on the ears, or eyes. I won't take it personal if you decide to not go any further, just go play with your new tabs and forms. Bye!</p>
<p>For those that want to keep going, lets add a new set of tabs for the users that <em>are</em> logged in so they can have some custom coolioness as a registered, AND logged in member of your site.</p>
<p>Remember that first chunk of HTML5 code I gave you at the beginning, which I told you to save for later? Well it's later. Grab that code, and paste it after this <span id="fixed">else</span> statement:</p>
<p><strong>Do it... or Else...!!</strong></p>
<pre class="brush: php; title: ; notranslate">

&lt;?php
else : // if they are logged in show submit form
?&gt;
</pre>
<p>This says, well tickle me purple, this person is logged in!! In that case, lets show them a cooler set of tabs with some exclusive members only content only the registered and logged in visitors can see!</p>
<h2>12: Only Showing Logged In Members Exclusive Tabs And Content</h2>
<p>Here's what I have done to that chunk of code I told you to grab and paste here after the <span id="fixed">else</span> statement. Did you do that? Or did you fail to follow my directions, again... It's okay, just copy this and use it instead of you want ;)</p>
<pre class="brush: php; title: ; notranslate">

&lt;div id=&quot;tabs&quot;&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;a href=&quot;#m-pages&quot;&gt;Members Only&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#m-tuts&quot;&gt;Members Tuts&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#m-chat&quot;&gt;Chat&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;div id=&quot;m-pages&quot;&gt;
		&lt;ul&gt;
			&lt;li&gt;For The Members&lt;/li&gt;
			&lt;li&gt;My Members Rule&lt;/li&gt;
			&lt;li&gt;Members Must Read&lt;/li&gt;
			&lt;li&gt;I Do re-Members&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/div&gt;
	&lt;div id=&quot;m-tuts&quot;&gt;
		&lt;ul&gt;
			&lt;li&gt;Special Tut (like this one but private)&lt;/li&gt;
			&lt;li&gt;A premium tutorial&lt;/li&gt;
			&lt;li&gt;Something special&lt;/li&gt;
			&lt;li&gt;Make a mustache man? wtf&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/div&gt;
	&lt;div id=&quot;m-chat&quot;&gt;&lt;!-- Post Form --&gt;
		&lt;div id=&quot;doyoulikechats&quot;&gt;
			You could chuck a &lt;a href=&quot;http://chatango.com&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;Chatango.com&lt;/a&gt; chat or something
			like that up in here, up in here, up in here.
		&lt;/div&gt;
	&lt;/div&gt;

&lt;/div&gt;
</pre>
<p><a href="http://new2wp.com/pro/jquery-tabbed-login-register-forms/attachment/allow-upload-contributor/" rel="attachment wp-att-953"><img src="http://new2wp.com/wp-content/uploads/2010/05/allow-upload-contributor.jpg" alt="Wordpress members" title="Wordpress members" width="200" height="200" class="alignleft size-full wp-image-953" /></a>Now maybe you want to have a list of privately published pages which you set up so only visitors that are logged in can access them. If not, here is another way to <a href="http://new2wp.com/noob/wordpress-members-only-pages/">create WordPress members only pages</a>, which you could set up, and list in the space for the first tab. Create some privately posted, members only tutorials on how to do some crazy super cool and insane shit. Yeah kinda like this tutorial, actually, exactly like this tutorial, only privately viewable to registered users. </p>
<p>Unlike this tutorial, but just as good. :P Last, maybe you want to have a chat for chitting away with your chatter-tat-tatters and sons. Or someone else that is registered on your site and likes talking to you. The possibilities to what these new members only tabs can hold is endless. All that we have left to do though, is END THIS!!!</p>
<h2>13: Let's End This Schnitzel</h2>
<p>So we need to put an <span id="fixed">endif;</span> we plan to ever end this. Ha! Did ya get it?!?! Clever bastard, I am, eh? Okay...</p>
<pre class="brush: php; title: ; notranslate">

&lt;?php
endif;
?&gt;
</pre>
<h2>That's All Folks</h2>
<p>Hope you liked this super custy amazed ation, makes me crave some more sensational stuff... </p>
<h2>How About A Bonus</h2>
<p>As promised, </p>
<h3>For Those, Less Up-to-Date WordPress Nuts</h3>
<p>Making a custom coded login form, is simple. You may already know how to do it just in making the register and password reset forms, but if not here we go.</p>
<p><a href="http://new2wp.com/pro/jquery-tabbed-login-register-forms/attachment/lostpass/" rel="attachment wp-att-936"><img src="http://new2wp.com/wp-content/uploads/2010/05/login.png" alt="login" title="login" width="400" height="154" class="aligncenter size-full wp-image-936" /></a></p>
<pre class="brush: php; title: ; notranslate">

&lt;form name=&quot;loginform&quot; id=&quot;loginform&quot; action=&quot;&lt;?php echo site_url('wp-login.php', 'login_post') ?&gt;&quot; method=&quot;post&quot;&gt;
	&lt;p&gt;
		&lt;label&gt;Username&lt;br&gt;
		&lt;input name=&quot;log&quot; id=&quot;user_login&quot; class=&quot;input&quot; value=&quot;&quot; size=&quot;20&quot; tabindex=&quot;10&quot; type=&quot;text&quot;&gt;&lt;/label&gt;
	&lt;/p&gt;
	&lt;p&gt;
		&lt;label&gt;Password&lt;br&gt;

		&lt;input name=&quot;pwd&quot; id=&quot;user_pass&quot; class=&quot;input&quot; value=&quot;&quot; size=&quot;20&quot; tabindex=&quot;20&quot; type=&quot;password&quot;&gt;&lt;/label&gt;
	&lt;/p&gt;
	&lt;p class=&quot;forgetmenot&quot;&gt;&lt;label&gt;&lt;input name=&quot;rememberme&quot; id=&quot;rememberme&quot; value=&quot;forever&quot; tabindex=&quot;90&quot; type=&quot;checkbox&quot;&gt; Remember Me&lt;/label&gt;&lt;/p&gt;
	&lt;p class=&quot;submit&quot;&gt;
		&lt;?php do_action('login_form', 'login'); ?&gt;
		&lt;input name=&quot;wp-submit&quot; id=&quot;wp-submit&quot; class=&quot;button-primary&quot; value=&quot;Log In&quot; tabindex=&quot;100&quot; type=&quot;submit&quot;&gt;
		&lt;input name=&quot;redirect_to&quot; value=&quot;&lt;?php bloginfo('template_directory').'/page-your_members_home_page.php'); ?&gt;&quot; type=&quot;hidden&quot;&gt;
		&lt;input name=&quot;testcookie&quot; value=&quot;1&quot; type=&quot;hidden&quot;&gt;
	&lt;/p&gt;

&lt;/form&gt;
</pre>
<h2>Finally That's it!!</h2>
<p>We made it through this long and drawn-out tutorial. You know, this is all readily open and available for you to view anytime you want had you just taken a second to think about it, you might have already thought about it and known. Then you wouldn't have needed to come follow my shenanigans here and you could've created this on your own. Just go check out the <a href="http://core.trac.wordpress.org/browser/trunk/wp-login.php">wp-login.php file</a>, and see for yourself. It has all the greatness I have gone through here, aside from the mustache reference Oh, and the tabs of course. </p>
<p>For those who are going to ask me if I have a demo set up, please check out my test site <a href="http://tweakurpages.com" rel="nofollow">here for a working example demonstration</a>. I have created a tabbed dialog box that displays the login/register and password reset forms which I am using on the theme I am currently developing. Click the Login button in the top right corner, and test the login out by using the following information:</p>
<p><strong>Username:</strong> themedemo<br />
<strong>Password:</strong> themedemo</p>
<p><a href="#add"><img src="http://new2wp.com/wp-content/uploads/2010/05/comment.png" alt="" title="comment" class="alignright size-full wp-image-953" /></a><br />
Any questions??? Post a comment, let me know what you're thinking, or what you've thought already. Enjoy!</p>
<div id="crp_related"><h3>Related Posts</h3><ul class="relatedposts"><li><a href="http://new2wp.com/noob/new2tip-allow-visitors-to-search-by-category/" rel="bookmark" class="crp_title">New2Tip: Allow Visitors To Search By Category</a></li><li><a href="http://new2wp.com/noob/how-to-make-a-simple-image-sliding-animation-with-jquery/" rel="bookmark" class="crp_title">How To Make A Simple Image Sliding Animation With jQuery</a></li><li><a href="http://new2wp.com/rookie/create-social-bookmark-buttons/" rel="bookmark" class="crp_title">Create Your Own Social Bookmark Button Links</a></li><li><a href="http://new2wp.com/rookie/sexy-rss-feeds-custom-content/" rel="bookmark" class="crp_title">Making Your RSS Feeds Sexy With Custom Content In WordPress</a></li><li><a href="http://new2wp.com/noob/adding-backwards-compatible-wordpress-menus-to-your-theme/" rel="bookmark" class="crp_title">Adding Backwards Compatible WordPress Menus To Your Theme</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://new2wp.com/pro/jquery-tabbed-login-register-forms/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>How To Make A Simple Image Sliding Animation With jQuery</title>
		<link>http://new2wp.com/noob/how-to-make-a-simple-image-sliding-animation-with-jquery/</link>
		<comments>http://new2wp.com/noob/how-to-make-a-simple-image-sliding-animation-with-jquery/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 16:45:06 +0000</pubDate>
		<dc:creator>Jared</dc:creator>
				<category><![CDATA[Demos]]></category>
		<category><![CDATA[Noob]]></category>
		<category><![CDATA[Rookie]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://new2wp.com/?p=539</guid>
		<description><![CDATA[Learn a quick and simple way to add some cool interactivity to your website. This tutorial shows how to use jQuery to make some sliding images for when you hover over them. 

Not every post has to be about Wordpress here, does it? ]]></description>
			<content:encoded><![CDATA[<h2>Why so much jQuery</h2>
<p>I realized that this is supposed to be a New 2 WordPress site, meaning we should be providing WordPress content, but the truth is there are so many sites out there like that already, I don't see the harm in providing a little something here and there that doesn't have to do with WordPress. Most of my posts contain something to do with jQuery, because I just love it. Plus you can easily incorporate jQuery into your WordPress site, so why not learn it, then try to use it in WP.  </p>
<h2>A cool image sliding animation</h2>
<p>In this simple tutorial, I'll show you how to make a basic animation that includes 2 images. When you hover over the image, it will slide down and reveal the 2nd image behind it. View the demo to see what I mean.</p>
<div class="example">
<div class="source"><a href="http://new2wp.com/labs/downloads/Sliding-images.zip" target="_blank">Download</a></div>
<div class="demo"><a href="http://new2wp.com/labs/sliding-images.html" target="_blank">Demo</a></div>
</div>
<h2>1. First we need some CSS Styling</h2>
<p>We want to add some styles to this, and CSS selectors that will be used later by the jQuery script. </p>
<pre class="brush: php; title: ; notranslate">
#container {
	width: 850px;
	text-align: center;
	margin: auto;
}
.wrap {
	width: 250px;
	height: 140px;
	position: relative;
	overflow: hidden;
	float: left;
	padding: 0 1em;
	top:150px;
}
img {
	position: absolute;
	top: 0;
	left: 4px;
}
</pre>
<h2>2. The HTML code</h2>
<p>The HTML we will use is as follows.</p>
<pre class="brush: php; title: ; notranslate">
&lt;div id=&quot;container&quot;&gt;

	&lt;div class=&quot;wrap&quot;&gt;
		&lt;img src=&quot;back.jpg&quot; alt=&quot;image&quot; /&gt;
		&lt;img src=&quot;front.jpg&quot; class=&quot;front&quot; alt=&quot;image&quot; /&gt;
	&lt;/div&gt;

	&lt;div class=&quot;wrap&quot;&gt;
		&lt;img src=&quot;back.jpg&quot; alt=&quot;image&quot; /&gt;
		&lt;img src=&quot;front.jpg&quot; class=&quot;front&quot; alt=&quot;image&quot; /&gt;
	&lt;/div&gt;   

	&lt;div class=&quot;wrap&quot;&gt;
		&lt;img src=&quot;back.jpg&quot; alt=&quot;image&quot; /&gt;
		&lt;img src=&quot;front.jpg&quot; class=&quot;front&quot; alt=&quot;image&quot; /&gt;
	&lt;/div&gt;

&lt;/div&gt;
</pre>
<p>You will see only the front image since the CSS overlaps the 2 images with the position of absolute for the img selector.</p>
<h2>3. The jQuery Script</h2>
<p>First thing is don't forget to include jQuery in the page.</p>
<pre class="brush: php; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.js&quot;&gt;&lt;/script&gt;
</pre>
<p>Then you can add the script, here I just embedded it in the page, since it's such a small script. Generally though you might want to include it as an external file.</p>
<pre class="brush: php; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot;&gt;
$(function() {
	$('.wrap').hover(function() {
		$(this).children('.front').stop().animate({ &quot;top&quot; : &quot;300px&quot;}, 700);
	}, function() {
		$(this).children('.front').stop().animate({ &quot;top&quot; : &quot;0px&quot;}, 200);

	});
});
&lt;/script&gt;
</pre>
<h3>Explained</h3>
<p><span id="fixed">$('.wrap').hover(function() {</span> This adds a hover function to the 'wrap' CSS class.</p>
<p><span id="fixed">$(this).children('.front').stop().animate({ "top" : "300px"}, 700);</span><br />
$(this) refers to the 'wrap', getting the .children of 'wrap' that have the class 'front'. The stop() function will stop the animation when you hover off, so the animations don't build up. The animate() function makes the 'front' image move down from the top by 300px at a speed of a little less more than half a second, 700.</p>
<p><span id="fixed">$(this).children('.front').stop().animate({ "top" : "0px"}, 200);</span><br />
This essentially does all the same stuff as the above except it slides it back up to 0px from the top, at a speed a little faster than half a second, 200.</p>
<h3>That's it!</h3>
<p>You could easily find ways to incorporate this into a WordPress theme. In fact that is what I have been working on with the new CSS Gallery Styleswitching thingy thing I am making. I don't really know what to call it, but it will basically become a really really cool jQuery CSS gallery, with lots of enhancements on CSS galleries as we know them. This will be one of those things. </p>
<p>Any questions let me know below.</p>
<div id="crp_related"><h3>Related Posts</h3><ul class="relatedposts"><li><a href="http://new2wp.com/noob/new2tip-allow-visitors-to-search-by-category/" rel="bookmark" class="crp_title">New2Tip: Allow Visitors To Search By Category</a></li><li><a href="http://new2wp.com/rookie/create-social-bookmark-buttons/" rel="bookmark" class="crp_title">Create Your Own Social Bookmark Button Links</a></li><li><a href="http://new2wp.com/noob/how-to-use-jquery-to-make-your-content-slide-toggle/" rel="bookmark" class="crp_title">How To Use jQuery To Make Your Content Slide Toggle</a></li><li><a href="http://new2wp.com/noob/adding-backwards-compatible-wordpress-menus-to-your-theme/" rel="bookmark" class="crp_title">Adding Backwards Compatible WordPress Menus To Your Theme</a></li><li><a href="http://new2wp.com/rookie/part-2-the-static-version-of-the-jquery-featured-post-slider/" rel="bookmark" class="crp_title">Part 2: The Static Version Of The jQuery Featured Post Slider</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://new2wp.com/noob/how-to-make-a-simple-image-sliding-animation-with-jquery/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Part 2: The Static Version Of The jQuery Featured Post Slider</title>
		<link>http://new2wp.com/rookie/part-2-the-static-version-of-the-jquery-featured-post-slider/</link>
		<comments>http://new2wp.com/rookie/part-2-the-static-version-of-the-jquery-featured-post-slider/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 18:54:51 +0000</pubDate>
		<dc:creator>Jared</dc:creator>
				<category><![CDATA[Demos]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Rookie]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Slider]]></category>

		<guid isPermaLink="false">http://new2wp.com/?p=279</guid>
		<description><![CDATA[This is where the fun begins. This is part 2 of creating a dynamic jQuery featured post slider that works with or without JavaScript. 

I guess you could say it's like 2 tutorials in 1, within a 3 tutorial series! Wow, that's a lot of tutorials.

]]></description>
			<content:encoded><![CDATA[<h2>Let's get started</h2>
<p>The first part of the tutorial talked about <a href="http://new2wp.com/pro/part-1-dynamic-jquery-featured-post-slider-with-or-without-javascript/">creating custom loops in WordPress</a> . In this part I'll show you how to set up the slider for combining both parts 1 and 2 together to dynamically display the posts in the Featured category of your site.</p>
<p>All you really need to know right now is that this will show you how to create a jQuery featured post slider that works without JavaScript. With this you can <a href="http://en.wikipedia.org/wiki/Progressive_enhancement">progressively enhance</a> your site, while increasing it's accessibility.<br />
<a href="http://page.ly/?a=79976200" title="WordPress Hosting" target="_blank"><img src="http://page.ly/public/gfx/ab/pagely468x60_7.gif" class="aligncenter" alt="WordPress Hosting" height="60" width="468"></a><br />
When adding this type of advanced feature, you want people not using JavaScript to still have access the content, while providing the cooler stuff to everyone else.</p>
<p>You could use this as it is if you wanted to edit the content that would show in it manually, but that's not what you will want to do after the next part in this series I'm sure.</p>
<div class="example">
<div class="source"><a href="http://new2wp.com/labs/jquery/static-jqueryslider/">Demo</a></div>
<div class="demo"><a href="http://new2wp.com/labs/jquery/static-jqueryslider/static-jqueryslider.zip" target=”_blank”>Download</a></div>
</div>
<p><strong>This tutorial is the second one of three in the series.</strong></p>
<ul>
<li><a href="http://new2wp.com/pro/part-1-dynamic-jquery-featured-post-slider-with-or-without-javascript/">Part 1: Creating Your Own Custom Loops In WordPress</a></li>
<li><a href="http://new2wp.com/rookie/part-2-the-static-version-of-the-jquery-featured-post-slider/">Part 2: The Static Version Of The jQuery Featured Post Slider</a></li>
<li><a href="http://new2wp.com/pro/part-3-making-a-dynamic-wordpress-jquery-featured-post-slider-tutorial-finale/">Part 3: Making A Dynamic WordPress jQuery Featured Post Slider </a></li>
</ul>
<p>The first thing you will need to do is download the <a href="http://malsup.com/jquery/cycle/" target="_blank">jQuery Cycle plugin</a>. Once you do, save it to the <span id="fixed">js</span> directory in your project root. Do this with the other JavaScript file you'll hear more about later. This tutorial is a variation on a <a href="http://net.tutsplus.com/tutorials/javascript-ajax/building-an-auto-scrolling-slideshow-that-works-with-and-without-javascript/" target="_blank">tutorial originally created</a> by <a href="http://twitter.com/jjenzz" target="_blank">Jenna Smith</a>. So I can not take full credit for creating it, I just modified it and made it work dynamically.</p>
<p>Here is what I'll be showing you how to make, which can be seen in action on the <a href="http://new2wp.com/labs/jquery/static-jqueryslider/">here on the demo page</a>.</p>
<p><a href="http://new2wp.com/labs/jquery/static-jqueryslider/"><img class="aligncenter size-full wp-image-306" style="border: 1px solid #182431;" title="jq-slider" src="http://new2wp.com/wp-content/uploads/2010/02/jq-slide.png" alt="jq-slider" width="549" height="273" /></a></p>
<h3>The HTML code</h3>
<p>Here is the HTML you need to use in your page. First the <span id="fixed">&lt;head&gt;</span> should have this.</p>
<pre class="brush: php; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;New2WP - jQuery Featured Post Slider&lt;/title&gt;

&lt;link rel=&quot;stylesheet&quot; href=&quot;slider-style.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery.cycle.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;js/slider.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
</pre>
<p>And here is the <span id="fixed">&lt;body&gt;</span> content of the page.</p>
<pre class="brush: php; title: ; notranslate">

&lt;body&gt;

&lt;div id=&quot;wrapper&quot;&gt;
	&lt;h1&gt;Demo - jQuery Featured Posts Slider&lt;/h1&gt;
	&lt;div id=&quot;slider&quot;&gt;

	&lt;!--Slider Navigation
	----------------------&gt;
		&lt;ul class=&quot;slides-nav&quot;&gt;
			&lt;li class=&quot;on&quot;&gt;&lt;a href=&quot;#slide-one&quot;&gt;Slide one&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href=&quot;#slide-two&quot;&gt;Slide two&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href=&quot;#slide-three&quot;&gt;Slide three&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href=&quot;#slide-four&quot;&gt;Slide four&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href=&quot;#slide-five&quot;&gt;Slide five?&lt;/a&gt;&lt;/li&gt;
		&lt;/ul&gt;

		&lt;!--Sliding Contents
		-------------------&gt;
		&lt;div class=&quot;slides&quot;&gt;
			&lt;ul&gt;
				&lt;li id=&quot;slide-one&quot;&gt;
					&lt;img src=&quot;http://new2wp.com/wp-content/uploads/2010/02/fun.png&quot; /&gt;
					&lt;h2&gt;Slide one&lt;/h2&gt;
					&lt;p&gt;And in the final tutorial, you would learn how to show excerpts of your posts here, instead of this static text. Yeah, take that you stupid static text! You'll also see how you can use wordpress custom fields to get and show a thumbnail image here, the image you see is also stupid and static.&lt;/p&gt;
				&lt;/li&gt;
				&lt;li id=&quot;slide-two&quot;&gt;
					&lt;img src=&quot;http://new2wp.com/wp-content/uploads/2010/02/fun.png&quot; /&gt;
					&lt;h2&gt;Slide two&lt;/h2&gt;
					&lt;p&gt;This works like a tab menu when Javascript is disabled. So you can always see what's here!&lt;/p&gt;
					&lt;p&gt;&lt;strong&gt;That's what's up.&lt;/strong&gt;&lt;/p&gt;
				&lt;/li&gt;
				&lt;li id=&quot;slide-three&quot;&gt;
					&lt;img src=&quot;http://new2wp.com/wp-content/uploads/2010/01/wordpress-loops.png&quot; /&gt;
					&lt;h2&gt;Slide three&lt;/h2&gt;
					&lt;p&gt;Post excerpts of your posts can be used, instead of this static text. Yeah, take that you stupid static text! You'll also see how you can use wordpress custom fields to get and show a thumbnail image here, the image you see is also stupid and static.&lt;/p&gt;
					&lt;p&gt;&lt;strong&gt;Well then, moving right along. Shall we?&lt;/strong&gt;&lt;/p&gt;
				&lt;/li&gt;
				&lt;li id=&quot;slide-four&quot;&gt;
					&lt;img src=&quot;http://new2wp.com/wp-content/uploads/2010/02/fun.png&quot; /&gt;
					&lt;h2&gt;Slide four&lt;/h2&gt;
					&lt;p&gt;Did you know? The industry's standard dummy text ever since the 1500s has been Lorem Ipsum, ever since an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.&lt;/p&gt;
				&lt;/li&gt;
				&lt;li id=&quot;slide-five&quot;&gt;
					&lt;img src=&quot;http://new2wp.com/wp-content/uploads/2010/01/wordpress-loops.png&quot; /&gt;
					&lt;h2&gt;Slide five&lt;/h2&gt;
					&lt;p&gt;If you are reading this, then you must be interested in what each slide says for some reason when that is not the point of this. But while you are reading this, you might be wondering why I made 5 slides for a demo page. It is what I created for the New2WP homepage slider, so therefore this tutorial will be more similar in looks to the thing I am showing you how to make, capiche?&lt;/p&gt;
				&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/div&gt;
	&lt;/div&gt;

&lt;/div&gt;&lt;!--/wrapper--&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>This has all the necessary code for building the 2 lists that display the slider navigation class <span id="fixed">#slides-nav</span> and the <span id="fixed">.slides</span> themselves.</p>
<h3>Adding CSS some styles and stuff</h3>
<p>The CSS is important here because without it certain things wouldn't work at all. jQuery and CSS go very well together, and you are able to do so many things by combining them. Though it can be difficult to work with if you don't <a href="http://getfirebug.com/" target="_blank">use Firebug</a> when you have <span id="fixed">divs</span> that are hidden or when you need to see the padding or margins of an element.</p>
<pre class="brush: php; title: ; notranslate">

/* slider
/* ---------------------------------------------------- */
#slider {
	background: #5a6173;
	border:0px solid #999;
	margin:0px;
	padding:10px;
	position:relative;
}
#slider ul {
	height: 1%; /* IE fix */
	list-style-type: none;
	padding: 0;
	position:relative;
}
#slider ul:after {
	clear: both;
	content: &quot;.&quot;;
	display: block;
	height: 0;
	visibility: hidden;
}

/* slider &gt; SLIDES
/* ---------------------------------------------------- */
.slides {
	border:1px solid #fff;
	background:#bdc3ce;
	color:#182431;
	padding:10px;
	position:abosolute;
	margin:10px;
}

.slides ul { width:9999px; }

.slides li {
	background:#bdc3ce;
	height:205px;
	margin:0px;
	overflow:hidden;
	padding:0px;
	position:relative;
	width: 470px; /* Width of slides box */
}
.slides h2, h2 a {
	font-size: 20px;
	margin:0px;
	padding:0px;
}
.slides img {
	float:left;
	margin-right:10px;
	overflow:hidden;
	padding:0px;
}
.slides p {
	margin:0px;
	overflow:hidden;
	padding:0px;
}

/* slider &gt; NAVIGATION
/* ---------------------------------------------------- */
.slides-nav {
	clear:both;
	float:right;
	position:absolute;
	right:10px; /* make this a negative number to make nav hang off */
	top:10px;
	width: 330px;
	z-index:100;
}
.slides-nav li { margin-left:4px; }

.slides-nav li a {
	background: #182431 url(images/inactive.png) left top repeat-x;
	color:#fff;
	display: block;
	font-size:14px;
	font-weight:bold;
	margin:0 0 0px 0;
	padding: 13px 5px;
	text-decoration:none;
}
</pre>
<p>For styling the highlighted tab, you can add this to your stylesheet.</p>
<pre class="brush: php; title: ; notranslate">

/* slider &gt; ACTIVE TAB
/* ---------------------------------------------------- */
.js #slider .slides-nav li.on a {
	background: url(images/active.png) left center no-repeat;
	color:#182431;
	margin:0 0 0 -15px;
	padding:12px 5px 12px 20px;
}
.js #slider .slides-nav li.on a {
	position: relative;
	top: 0px;
}
</pre>
<p>You can of course edit the styles to suit your needs, this is just the CSS I created for the slider on the <a href="http://new2wp.com/labs/jquery/static-jqueryslider/">demo</a> so you can see what it looks like.</p>
<h2>Finally we write the jQuery code</h2>
<p>Since the we included the jQuery library, and other JavaScript files in the page HTML already, all we need to do is create the slider script.</p>
<pre class="brush: php; title: ; notranslate">

$slider = {
    context: false,
    tabs: false,
    timeout: 1000,      // time before next slide appears (in ms)
    slideSpeed: 1000,   // time it takes to slide in each slide (in ms)
    tabSpeed: 300,      // time it takes to slide in each slide (in ms) when rotating through tabs
    fx: 'scrollLeft',   // slide control: fade, scrollLeft, right etc.

    init: function() {
        // set the context to help speed up selectors/improve performance
        this.context = $('#slider');

        // set tabs to current hard coded navigation items
        this.tabs = $('ul.slides-nav li', this.context);

        // remove hard coded navigation items from DOM
        // because they aren't hooked up to jQuery cycle
        this.tabs.remove();

        // prepare slider and jQuery cycle tabs
        this.prepareSlideshow();
    },
    prepareSlideshow: function() {
        // initialise the jquery cycle plugin -
        // for information on the options set below go to:
        // http://malsup.com/jquery/cycle/options.html
        $('div.slides &gt; ul', $slider.context).cycle({
            fx: $slider.fx,
            timeout: $slider.timeout,
            speed: $slider.slideSpeed,
            fastOnEvent: $slider.tabSpeed,
            pager: $('ul.slides-nav', $slider.context),
            pagerAnchorBuilder: $slider.prepareTabs,
            before: $slider.activateTab,
            pauseOnPagerHover: true,
            pause: true
        });
    },
    prepareTabs: function(i, slide) {
        // return markup from hardcoded tabs for use as jQuery cycle tabs
        // (attaches necessary jQuery cycle events to tabs)
        return $slider.tabs.eq(i);
    },
</pre>
<p>The part above sets up the slider, and prepares the slides. You can control the slider using more parameters than this, just visit the <a href="http://malsup.com/jquery/cycle/" target="_blank">options page of the Cycle plugin</a></p>
<p>Next is the part that sets up and controls the tabs so they will cycle through showing each as highlighted.</p>
<pre class="brush: php; title: ; notranslate">

    activateTab: function(currentSlide, nextSlide) {
        // get the active tab
        var activeTab = $('a[href=&quot;#' + nextSlide.id + '&quot;]', $slider.context);

        // if there is an active tab
		if(activeTab.length) {
            // remove active styling from all other tabs
            $slider.tabs.removeClass('on');
            // add active styling to active button
            activeTab.parent().addClass('on');
        }
    }
};
</pre>
<p>This last part is to make sure the first tab is highlighted when the page first loads.</p>
<pre class="brush: php; title: ; notranslate">

$(function() {
    // add a 'js' class to the body
    $('body').addClass('js');
    // initialise the slider when the DOM is ready
    $slider.init();
});
</pre>
<h2>What makes it work without JavaScript...</h2>
<p>Included in the code for the HTML page, you will notice that each slide has an ID set. To get this to work like a tab menu box all you have to do is reference the same ID in the corresponding href of each navigation link, like so:</p>
<pre class="brush: php; title: ; notranslate">

// This is the nav button for slide one
&lt;a href=&quot;#slide-one&quot;&gt;Slide one&lt;/a&gt;&lt;/li&gt;

// this is the ID of slide one
&lt;li id=&quot;slide-one&quot;&gt;
</pre>
<p>Just match the slide ID's to the nav href's. It's as simple as that. I think that concludes this tutorial. You will want to make sure to check out <a href="#">Part 3: making a dynamic featured post slider</a> by combining <a href="http://new2wp.com/pro/part-1-dynamic-jquery-featured-post-slider-with-or-without-javascript/">Part 1: creating your own custom loops in WordPress</a>, and <a href="part-2-the-static-version-of-the-jquery-featured-post-slider">Part 2: creating a static jQuery featured post slider</a>. It will help you take your site to the 'next-level' and you'll learn some stuff too.</p>
<p>If you have any questions about the code let me know in the comments. It's already taken way longer to finish this post than I wanted it to. Plus there was a delay since I've been working on providing a better syntax code view for the site, and it is turning into a larger project than I intended it to. Time to make the donuts!</p>
<div id="crp_related"><h3>Related Posts</h3><ul class="relatedposts"><li><a href="http://new2wp.com/pro/part-3-making-a-dynamic-wordpress-jquery-featured-post-slider-tutorial-finale/" rel="bookmark" class="crp_title">Part 3: Making A Dynamic WordPress jQuery Featured Post Slider Tutorial</a></li><li><a href="http://new2wp.com/pro/part-1-dynamic-jquery-featured-post-slider-with-or-without-javascript/" rel="bookmark" class="crp_title">Part 1: Dynamic jQuery Featured Post Slider &#8211; Using Custom Loops</a></li><li><a href="http://new2wp.com/noob/how-to-make-a-simple-image-sliding-animation-with-jquery/" rel="bookmark" class="crp_title">How To Make A Simple Image Sliding Animation With jQuery</a></li><li><a href="http://new2wp.com/noob/how-to-use-jquery-to-make-your-content-slide-toggle/" rel="bookmark" class="crp_title">How To Use jQuery To Make Your Content Slide Toggle</a></li><li><a href="http://new2wp.com/pro/jquery-drop-down-menu-wordpress-3-menu/" rel="bookmark" class="crp_title">Create A WordPress 3.0 jQuery Drop Down Nav Menu</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://new2wp.com/rookie/part-2-the-static-version-of-the-jquery-featured-post-slider/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Part 1: Dynamic jQuery Featured Post Slider &#8211; Using Custom Loops</title>
		<link>http://new2wp.com/pro/part-1-dynamic-jquery-featured-post-slider-with-or-without-javascript/</link>
		<comments>http://new2wp.com/pro/part-1-dynamic-jquery-featured-post-slider-with-or-without-javascript/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 15:00:00 +0000</pubDate>
		<dc:creator>Jared</dc:creator>
				<category><![CDATA[Demos]]></category>
		<category><![CDATA[Pro]]></category>
		<category><![CDATA[Rookie]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Loops]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://new2wp.com/?p=36</guid>
		<description><![CDATA[Now that I have pretty much completed the awesomely cool, and dynamic, jQuery featured post slider you see at the top of the homepage, I've decided to write a multiple post tutorial on how to create something like it yourself.

This first part will cover the basics of creating Wordpress custom loops, which you will need to know to make things like the slider dynamically pull content from posts.]]></description>
			<content:encoded><![CDATA[<h2>Getting to know your loopy side</h2>
<p>Now you're probably here because you were either curious about the title of this post, or you're interested in learning how to create your own custom WordPress loops using <span id="fixed">WP_Query()</span>. Or maybe you just love reading my amazing posts of nonsense. </p>
<p><strong>Tutorials in this series</strong></p>
<ul>
<li><a href="http://new2wp.com/pro/part-1-dynamic-jquery-featured-post-slider-with-or-without-javascript/">Part 1: Creating Your Own Custom Loops In WordPress</a></li>
<li><a href="http://new2wp.com/rookie/part-2-the-static-version-of-the-jquery-featured-post-slider/">Part 2: The Static Version Of The jQuery Featured Post Slider</a></li>
<li><a href="http://new2wp.com/pro/part-3-making-a-dynamic-wordpress-jquery-featured-post-slider-tutorial-finale/">Part 3: Making A Dynamic WordPress jQuery Featured Post Slider </a></li>
</ul>
<p>Those here for learning about WordPress loops will be happy to hear that not only is this going to be about making your own loops, but it will be the first post of my multi-post tutorial for creating the cool jQuery featured post slider you can see on the <a href="/">homepage</a> of the site. It took some time to get working, and I'm quite satisfied with how it came out.</p>
<p><img src="http://new2wp.com/wp-content/uploads/2010/01/myfeat-slider.png" alt="" title="myfeat-slider" width="450" height="200" class="aligncenter size-full wp-image-256" /></p>
<p><strong>Here's what sort of things this tutorial series covers:</strong></p>
<ul>
<li><strong>Part 1:</strong> How to make your own custom loops in WordPress using <span id="fixed">WP_Query</span></li>
<li><strong>Part 2:</strong> Coding the jQuery and CSS slider to work with or without JavaScript enabled using the <a href="http://malsup.com/jquery/cycle/" target="_blank">jQuery Cycle plugin</a></li>
<li><strong>Part 3:</strong> Putting it all together to dynamically show posts from the "featured" category in the slider</li>
</ul>
<p>Other cool tricks you'll learn:</p>
<ul>
<li>How to easily shorten post titles, excerpts, posts etc.</li>
<li>Retrieve and display content from custom fields</li>
<li>jQuery awesomeness</li>
</ul>
<h2>Creating your own custom loops</h2>
<p>There <a href="http://www.smashingmagazine.com/2009/06/10/10-useful-wordpress-loop-hacks/" target="_blank">are many reasons</a> you might want to create custom loops, and the possibilities are endless for what you come up with too. It's a great way to have full control over what is displayed on the page. For example, the featured post slider I'll be making has specific settings in the loop that control what category ID to pull posts from and how many of them I want to get. </p>
<p>You could also use it to get a custom field with a specific value, or to create a custom archives page if you wanted to. There are so many good reasons to learn how to make your own loops.</p>
<p><strong>Show me the code already!</strong></p>
<p>You might be somewhat familiar with this already if you know what the <a href="http://www.themelab.com/2008/04/04/the-ultimate-guide-to-the-wordpress-loop/" target="_blank">WordPress Loop</a> or <a href="http://codex.wordpress.org/Template_Tags/query_posts" target="_blank">query_posts()</a>. If you have no clue what that is, then you should <a href="http://weblogtoolscollection.com/archives/2007/06/06/global-variables-and-the-wordpress-loop/" target="_blank">read more about it</a> because it's kind of a big deal, and very <a href="http://www.blogherald.com/2007/05/31/a-wordpress-developers-best-friend/" target="_blank">important to know</a> if you plan to develop with WordPress.</p>
<pre class="brush: php; title: ; notranslate">

$my_posts = new WP_Query();
$my_posts-&gt;query('showposts=NUMBER_OF_POSTS&amp;cat=CATEGORY_ID'); // what to get
	while ($my_posts-&gt;have_posts()) : $my_posts-&gt;the_post(); // loop for posts

	// make your magic happen here
	// do a little dance...

 endwhile; // end loop 
</pre>
<p>First I created the variable <span id="fixed">$my_posts</span>, and instantiated an instance of <span id="fixed">WP_Query</span>. The used a method of <span id="fixed">WP_Query</span> to start a query. For this you can use the <a href="http://codex.wordpress.org/Template_Tags/query_posts#Parameters" target="_blank">same parameters</a> as with <span id="fixed">query_posts()</span> since it's basically the same thing.</p>
<p>Then I start the loop using <span id="fixed">while($my_posts->have_posts())</span>, which basically means while I have the posts, show them using <span id="fixed">$my_posts->the_post()</span>.</p>
<h2>A look at the slider loop</h2>
<p>I'll be using the same thing as above for the slider with an included <span id="fixed">for()</span> loop to increment the slide id's and classes. </p>
<p>The loop will be used 2 separate times in order to show the 2 lists. One that will generate the tab navigation showing a shortened version of <span id="fixed">the_title()</span> so it fits in the tab, and one to generate the post content slides. If you happen know of an easier way to do it after finishing the tutorial let me know.</p>
<pre class="brush: php; title: ; notranslate">

$featuredPosts = new WP_Query();
$featuredPosts-&gt;query('showposts=5&amp;cat=28');
for($i=1; $i&lt;=$featuredPosts; $i++) { // start for loop to loop increment slide classes
	while ($featuredPosts-&gt;have_posts()) : $featuredPosts-&gt;the_post(); // loop for posts titles
</pre>
<p>So that's what's up as far as custom looping. Stay tuned for the next part of the series to learn how to make a static version of the jQuery slider. It will be like a tutorial within a tutorial since you could choose to use the slider statically. </p>
<p><strong>Update 2:</strong> The second part and third parts in this tutorial series is complete. </p>
<ul>
<li><a href="http://new2wp.com/pro/part-1-dynamic-jquery-featured-post-slider-with-or-without-javascript/">Part 1: Creating Your Own Custom Loops In WordPress</a></li>
<li><a href="http://new2wp.com/rookie/part-2-the-static-version-of-the-jquery-featured-post-slider/">Part 2: The Static Version Of The jQuery Featured Post Slider</a></li>
<li><a href="http://new2wp.com/pro/part-3-making-a-dynamic-wordpress-jquery-featured-post-slider-tutorial-finale/">Part 3: Making A Dynamic WordPress jQuery Featured Post Slider </a></li>
</ul>
<div id="crp_related"><h3>Related Posts</h3><ul class="relatedposts"><li><a href="http://new2wp.com/noob/query_posts-wp_query-differences/" rel="bookmark" class="crp_title">Understanding The Difference Between query_posts and WP_Query</a></li><li><a href="http://new2wp.com/noob/show-multiple-custom-post-type-posts-query-sidebar/" rel="bookmark" class="crp_title">Showing Posts From Multiple Custom Post Types In The Loop</a></li><li><a href="http://new2wp.com/pro/part-3-making-a-dynamic-wordpress-jquery-featured-post-slider-tutorial-finale/" rel="bookmark" class="crp_title">Part 3: Making A Dynamic WordPress jQuery Featured Post Slider Tutorial</a></li><li><a href="http://new2wp.com/rookie/part-2-the-static-version-of-the-jquery-featured-post-slider/" rel="bookmark" class="crp_title">Part 2: The Static Version Of The jQuery Featured Post Slider</a></li><li><a href="http://new2wp.com/noob/new2wp-launch-learn-even-more-about-wordpress/" rel="bookmark" class="crp_title">New2WP.com Launch: Learn Even More About WordPress</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://new2wp.com/pro/part-1-dynamic-jquery-featured-post-slider-with-or-without-javascript/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

