<?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>bavotasan.com &#187; List</title>
	<atom:link href="http://bavotasan.com/tag/list/feed/" rel="self" type="application/rss+xml" />
	<link>http://bavotasan.com</link>
	<description>by c.bavota</description>
	<lastBuildDate>Tue, 07 Feb 2012 15:42:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>An Even Better Author List in WordPress</title>
		<link>http://bavotasan.com/2011/an-even-better-author-list-in-wordpress/</link>
		<comments>http://bavotasan.com/2011/an-even-better-author-list-in-wordpress/#comments</comments>
		<pubDate>Fri, 30 Sep 2011 17:11:32 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Authors]]></category>
		<category><![CDATA[contributors]]></category>
		<category><![CDATA[get_users()]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=3665</guid>
		<description><![CDATA[I already wrote about this a while back in &#8220;How to Display an Author List with Avatars in WordPress&#8221; but I recently realized that it needed updating. There&#8217;s a better way of collecting and displaying all the information and you can also add a few variables to give you more control over the output. Let&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://bavotasan.com/wp-content/uploads/2011/09/author_big.jpg" alt="" title="author_big" width="550" height="200" class="aligncenter size-full wp-image-3682" />I already wrote about this a while back in <a href="http://bavotasan.com/2009/how-to-display-an-author-list-with-avatars-in-wordpress/">&#8220;How to Display an Author List with Avatars in WordPress&#8221;</a> but I recently realized that it needed updating. There&#8217;s a better way of collecting and displaying all the information and you can also add a few variables to give you more control over the output.</p>
<p>Let&#8217;s start off with creating our variables:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$display_admins</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$order_by</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'display_name'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 'nicename', 'email', 'url', 'registered', 'display_name', or 'post_count'</span>
<span style="color: #000088;">$role</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 'subscriber', 'contributor', 'editor', 'author' - leave blank for 'all'</span>
<span style="color: #000088;">$avatar_size</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">32</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$hide_empty</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// hides authors with zero posts</span></pre></div></td></tr></table></div>

<p>Next we can add the code to gather our contributors:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><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;">$display_admins</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$blogusers</span> <span style="color: #339933;">=</span> get_users<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'orderby='</span><span style="color: #339933;">.</span><span style="color: #000088;">$order_by</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;role='</span><span style="color: #339933;">.</span><span style="color: #000088;">$role</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$admins</span> <span style="color: #339933;">=</span> get_users<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'role=administrator'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$exclude</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$admins</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$ad</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$exclude</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ad</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$exclude</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #000088;">$exclude</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$blogusers</span> <span style="color: #339933;">=</span> get_users<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'exclude='</span><span style="color: #339933;">.</span><span style="color: #000088;">$exclude</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;orderby='</span><span style="color: #339933;">.</span><span style="color: #000088;">$order_by</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;role='</span><span style="color: #339933;">.</span><span style="color: #000088;">$role</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$authors</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$blogusers</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$bloguser</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> get_userdata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bloguser</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$hide_empty</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$numposts</span> <span style="color: #339933;">=</span> count_user_posts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$numposts</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$authors</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$user</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div>

<p>Now that we have all the information we need, let&#8217;s display it:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;ul class=&quot;contributors&quot;&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$authors</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$author</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$display_name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$author</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'display_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$avatar</span> <span style="color: #339933;">=</span> get_avatar<span style="color: #009900;">&#40;</span><span style="color: #000088;">$author</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ID'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$avatar_size</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$author_profile_url</span> <span style="color: #339933;">=</span> get_author_posts_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$author</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ID'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;li&gt;&lt;a href=&quot;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$author_profile_url</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$avatar</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/a&gt;&lt;a href=&quot;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$author_profile_url</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&quot; class=&quot;contributor-link&quot;&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$display_name</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/a&gt;&lt;/li&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/ul&gt;'</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div>

<p>If we put all the code together we get the following:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$display_admins</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$order_by</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'display_name'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 'nicename', 'email', 'url', 'registered', 'display_name', or 'post_count'</span>
<span style="color: #000088;">$role</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 'subscriber', 'contributor', 'editor', 'author' - leave blank for 'all'</span>
<span style="color: #000088;">$avatar_size</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">32</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$hide_empty</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// hides authors with zero posts</span>
&nbsp;
<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;">$display_admins</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$blogusers</span> <span style="color: #339933;">=</span> get_users<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'orderby='</span><span style="color: #339933;">.</span><span style="color: #000088;">$order_by</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;role='</span><span style="color: #339933;">.</span><span style="color: #000088;">$role</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$admins</span> <span style="color: #339933;">=</span> get_users<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'role=administrator'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$exclude</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$admins</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$ad</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$exclude</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ad</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$exclude</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #000088;">$exclude</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$blogusers</span> <span style="color: #339933;">=</span> get_users<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'exclude='</span><span style="color: #339933;">.</span><span style="color: #000088;">$exclude</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;orderby='</span><span style="color: #339933;">.</span><span style="color: #000088;">$order_by</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;role='</span><span style="color: #339933;">.</span><span style="color: #000088;">$role</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$authors</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$blogusers</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$bloguser</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> get_userdata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bloguser</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$hide_empty</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$numposts</span> <span style="color: #339933;">=</span> count_user_posts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$numposts</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$authors</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$user</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;ul class=&quot;contributors&quot;&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$authors</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$author</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$display_name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$author</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'display_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$avatar</span> <span style="color: #339933;">=</span> get_avatar<span style="color: #009900;">&#40;</span><span style="color: #000088;">$author</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ID'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$avatar_size</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$author_profile_url</span> <span style="color: #339933;">=</span> get_author_posts_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$author</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ID'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;li&gt;&lt;a href=&quot;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$author_profile_url</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$avatar</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/a&gt;&lt;a href=&quot;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$author_profile_url</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&quot; class=&quot;contributor-link&quot;&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$display_name</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/a&gt;&lt;/li&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/ul&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

<p>All it needs is a little CSS to style it:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.contributors</span> <span style="color: #6666ff;">.avatar</span> <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;">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;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ccc</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>
	-webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>
	box-sizing<span style="color: #00AA00;">:</span> content-box<span style="color: #00AA00;">;</span> 
	-moz-box-sizing<span style="color: #00AA00;">:</span> content-box<span style="color: #00AA00;">;</span> 
	-webkit-box-sizing<span style="color: #00AA00;">:</span> content-box<span style="color: #00AA00;">;</span> 
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #6666ff;">.contributors</span> <span style="color: #6666ff;">.avatar</span><span style="color: #3333ff;">:hover  </span><span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">border-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span>
		<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.contributors</span> <span style="color: #6666ff;">.contributor-link</span> <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: #933;">10px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span></pre></div></td></tr></table></div>

<p>You can play around with the CSS to get it looking the way you want and with the variables in place, you can control exactly what type of author list will be displayed.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2011/an-even-better-author-list-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Using Ajax with WordPress</title>
		<link>http://bavotasan.com/2010/using-ajax-with-wordpress/</link>
		<comments>http://bavotasan.com/2010/using-ajax-with-wordpress/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 18:53:53 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[feedback]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[look]]></category>
		<category><![CDATA[magazine]]></category>
		<category><![CDATA[mailing]]></category>
		<category><![CDATA[person]]></category>
		<category><![CDATA[way]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=2586</guid>
		<description><![CDATA[A little while back, I updated Magazine Basic and added the Ajax save function. When I uploaded it to WordPress to await approval, I received some feedback on how I could incorporate Ajax using the admin-ajax.php file instead of the sloppy way I had it coded. All of the core Ajax functions in WordPress rely [...]]]></description>
			<content:encoded><![CDATA[<p>A little while back, I updated Magazine Basic and added the Ajax save function. When I uploaded it to WordPress to await approval, I received some feedback on how I could incorporate Ajax using the <code>admin-ajax.php</code> file instead of the sloppy way I had it coded. All of the core Ajax functions in WordPress rely on <code>admin-ajax.php</code> and using it for custom scripts is extremely easy to implement. </p>
<p>Let&#8217;s take a look at all the pieces you need to get it working. In this example I will build a small mailing list function that will send out an email to the admin when a person clicks submit.</p>
<p>Here&#8217;s our form:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">&lt;form method=&quot;post&quot; id=&quot;mailinglist&quot; action=&quot;&quot;&gt;
	&lt;div id=&quot;message&quot;&gt;&lt;/div&gt;
	&lt;input type=&quot;text&quot; name=&quot;mailinglistemail&quot; id=&quot;mailinglistemail&quot; /&gt;
	&lt;input type=&quot;submit&quot; name=&quot;submit&quot; id=&quot;mailinglistsubmit&quot; value=&quot;Join&quot; /&gt;&lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> admin_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/wp-admin/images/wpspin_light.gif&quot; alt=&quot;&quot; class=&quot;ajaxsave&quot; style=&quot;display: none;&quot; /&gt;
&lt;/form&gt;</pre></div></td></tr></table></div>

<p>Here&#8217;s the jQuery:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery<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>
	jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglist&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">submit</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: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglistemail&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglist #message&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Please enter your email address.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> email <span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#mailinglistemail'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>email.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;@&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span> <span style="color: #339933;">||</span> email.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglist #message&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Please enter a valid email address.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #003366; font-weight: bold;">var</span> data <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
					action<span style="color: #339933;">:</span> <span style="color: #3366CC;">'join_mailinglist'</span><span style="color: #339933;">,</span>
					email<span style="color: #339933;">:</span> email
				<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
				jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglistsubmit&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.ajaxsave&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				jQuery.<span style="color: #660066;">post</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;?php echo admin_url('admin-ajax.php'); ?&gt;&quot;</span><span style="color: #339933;">,</span> data<span style="color: #339933;">,</span>
				<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
					jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.ajaxsave&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglistsubmit&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglist #message&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>response<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: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span> 
&nbsp;
	<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></pre></div></td></tr></table></div>

<p>Let me explain each part. </p>
<p>When a user clicks submit, we need to check that the email field is not empty. If it is empty, we let the user know by sending the &#8220;Please enter your email address.&#8221; message and we stop the form from being submitted by including the <code>return false;</code> line.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglistemail&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglist #message&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Please enter your email address.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div>

<p>Next, we&#8217;ll do a simple validation to make sure the email address actually contains the @ symbol and a period. If not, send an error message and return false.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> email <span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#mailinglistemail'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>email.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;@&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span> <span style="color: #339933;">||</span> email.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglist #message&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Please enter a valid email address.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div>

<p>Once all that is done and everything is good, we can submit our form. This is where <code>admin-ajax.php</code> comes into play. When using <code>admin-ajax.php</code>, you need to include an action callback to make it work. Our callback is <code>join_mailinglist</code>. This is going to interact with our PHP to make everything work on the backend. Let&#8217;s create a data variable to store our action and our email value.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> data <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	action<span style="color: #339933;">:</span> <span style="color: #3366CC;">'join_mailinglist'</span><span style="color: #339933;">,</span>
	email<span style="color: #339933;">:</span> email
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div>

<p>Now we will hide our submit button and have a loader graphic appear to let people know something is going on. Then will will use the jQuery <a href="http://api.jquery.com/jQuery.post/">.post</a> function to send everything out to the <code>admin-ajax.php</code> file. Once the function is complete and a response is given, the loader will disappear, the submit button will return and a success message, or error message will indicate what happened.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglistsubmit&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.ajaxsave&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
jQuery.<span style="color: #660066;">post</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;?php echo admin_url('admin-ajax.php'); ?&gt;&quot;</span><span style="color: #339933;">,</span> data<span style="color: #339933;">,</span>
<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.ajaxsave&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglistsubmit&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglist #message&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>response<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: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div>

<p>With the form and the jQuery in place, all we need now is some PHP. </p>
<p>The <code>admin-ajax.php</code> file requires two action filters.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_ajax_my_action'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_action_callback'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_ajax_nopriv_my_action'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_action_callback'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div>

<p>The first action will only work if users are logged in. The second is if users don&#8217;t have to be logged in. For our requirements, it should look like this:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_ajax_join_mailinglist'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'join_mailinglist_callback'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_ajax_nopriv_join_mailinglist'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'join_mailinglist_callback'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div>

<p>Here is our join_mailinglist_callback function, which needs to be added to <code>functions.php</code>:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> join_mailinglist_callback<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$email</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</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;">$email</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$yourEmail</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'c@bavotasan.com'</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$subject</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Add me to your mailing list'</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$success</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$yourEmail</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subject</span><span style="color: #339933;">,</span> <span style="color: #000088;">$email</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$success</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Your email is subscribed to our mailing list.'</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'There was a problem. Please try again.'</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div>

<p>With everything in place, you will get a form that works like the one below.</p>
<form method="post" id="mailinglist" action="">
<div id="message"></div>
<input type="text" name="mailinglistemail" id="mailinglistemail" />
<input type="submit" name="submit" id="mailinglistsubmit" value="Join" /><img src="http://bavotasan.com/wp-admin/images/wpspin_light.gif" alt="" class="ajaxsave" style="display: none;" /><br />
</form>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2010/using-ajax-with-wordpress/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The New Google Font API</title>
		<link>http://bavotasan.com/2010/google-font-api/</link>
		<comments>http://bavotasan.com/2010/google-font-api/#comments</comments>
		<pubDate>Mon, 24 May 2010 15:55:04 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[body]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[Css File]]></category>
		<category><![CDATA[Directory]]></category>
		<category><![CDATA[face kits]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[font]]></category>
		<category><![CDATA[Fonts]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[head tags]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[look]]></category>
		<category><![CDATA[New]]></category>
		<category><![CDATA[serif]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[Stylesheet]]></category>
		<category><![CDATA[use]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=2074</guid>
		<description><![CDATA[Using the standard Web safe fonts is quickly becoming a thing of the past thanks to modern alternatives like @font-face kits and the new Google Font API. Taking a quick look through the Getting Started guide shows just how simple it is to apply the API to your Web site. All you have to do [...]]]></description>
			<content:encoded><![CDATA[<p>Using the standard Web safe fonts is quickly becoming a thing of the past thanks to modern alternatives like @font-face kits and the new <a href="http://code.google.com/apis/webfonts/">Google Font API</a>.  Taking a quick look through the <a href="http://code.google.com/apis/webfonts/docs/getting_started.html">Getting Started</a> guide shows just how simple it is to apply the API to your Web site. All you have to do is add a link between your site&#8217;s head tags to the CSS file hosted on Google, and then you can call the chosen font throughout your stylesheet.<br />
<span id="more-2074"></span><br />
Here is an example of the link:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>link rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;stylesheet&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/css&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://fonts.googleapis.com/css?family=Tangerine&quot;</span><span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p>Then you can use the font like this:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="css" style="font-family:monospace;">&lt;style<span style="color: #00AA00;">&gt;</span>
      body <span style="color: #00AA00;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">'Tangerine'</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">serif</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;">48px</span><span style="color: #00AA00;">;</span>
      <span style="color: #00AA00;">&#125;</span>
&lt;/style<span style="color: #00AA00;">&gt;</span></pre></div></td></tr></table></div>

<p>Check out a list of available font in the <a href="http://code.google.com/webfonts">font directory</a>. They are all licensed for commercial and non-commercial use.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2010/google-font-api/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>8 jQuery Plugins to Improve the Way your Forms Look</title>
		<link>http://bavotasan.com/2010/8-jquery-plugins-improve-forms-look/</link>
		<comments>http://bavotasan.com/2010/8-jquery-plugins-improve-forms-look/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 19:55:38 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[bit]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[default]]></category>
		<category><![CDATA[Default Theme]]></category>
		<category><![CDATA[dfc]]></category>
		<category><![CDATA[drop]]></category>
		<category><![CDATA[Elements]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[Job]]></category>
		<category><![CDATA[jqTransform]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[Little Bit]]></category>
		<category><![CDATA[Luckily]]></category>
		<category><![CDATA[Mouse Click]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Style]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=1887</guid>
		<description><![CDATA[When it comes to forms, every browser displays inputs, select drop downs and buttons differently. You can style certain elements using CSS but things like radio buttons and checkboxes are determined by the browser. Luckily, there are some cool jQuery plugins available that help you add a little bit more style to your forms. Here [...]]]></description>
			<content:encoded><![CDATA[<p>When it comes to forms, every browser displays inputs, select drop downs and buttons differently. You can style certain elements using CSS but things like radio buttons and checkboxes are determined by the browser. Luckily, there are some cool jQuery plugins available that help you add a little bit more style to your forms.<br />
<span id="more-1887"></span><br />
Here are a list of jQuery plugins that can help get your forms looking a bit more impressive:</p>
<div class="lists">
<div class="sections">
<h2>jqTransform</h2>
<p><img src="http://bavotasan.com/wp-content/uploads/2010/04/jqtransform.jpg" alt="" title="jqtransform" width="560" height="163" class="alignleft size-full wp-image-1888" /><br />
jqTransform allows you to skin form elements with color changes on both mouse rollover and mouse click event.<br />
<a href="http://www.dfc-e.com/metiers/multimedia/opensource/jqtransform/">http://www.dfc-e.com/metiers/multimedia/opensource/jqtransform/</a></p>
<p><strong>Example</strong>:<br />
<img src="http://bavotasan.com/wp-content/uploads/2010/04/jqtransform_example.jpg" alt="" title="jqtransform_example" width="520" height="580" class="aligncenter size-full wp-image-1889" />
</div>
<div class="sections">
<h2>Niceforms</h2>
<p><img src="http://bavotasan.com/wp-content/uploads/2010/04/niceform.jpg" alt="" title="niceform" width="560" height="163" class="alignleft size-full wp-image-1895" /><br />
Niceforms is a script that will replace the most commonly used form elements with custom designed ones. You can either use the default theme that is provided or you can even develop your own look with minimal effort.<br />
<a href="http://www.emblematiq.com/lab/niceforms/">http://www.emblematiq.com/lab/niceforms/</a></p>
<p><strong>Example</strong>:<br />
<img src="http://bavotasan.com/wp-content/uploads/2010/04/niceforms_examples.jpg" alt="" title="niceforms_examples" width="560" height="651" class="alignleft size-full wp-image-1896" />
</div>
<div class="sections">
<h2>Uniform</h2>
<p><img src="http://bavotasan.com/wp-content/uploads/2010/04/uniform.jpg" alt="" title="uniform" width="560" height="163" class="alignleft size-full wp-image-1919" /><br />
Uniform masks your standard form controls with custom themed controls. It works in sync with your real form elements to ensure accessibility and compatibility.<br />
<a href="http://pixelmatrixdesign.com/uniform/">http://pixelmatrixdesign.com/uniform/</a></p>
<p><strong>Example</strong>:<br />
<img src="http://bavotasan.com/wp-content/uploads/2010/04/uniform_example.jpg" alt="" title="uniform_example" width="453" height="179" class="alignleft size-full wp-image-1920" />
</div>
<div class="sections">
<h2>jNice</h2>
<p><img src="http://bavotasan.com/wp-content/uploads/2010/04/jnice.jpg" alt="" title="jnice" width="560" height="163" class="alignleft size-full wp-image-1900" /><br />
jNice helps you create custom looking form elements that function like normal form elements using jQuery and CSS.<br />
<a href="http://plugins.jquery.com/project/jNice">http://plugins.jquery.com/project/jNice</a></p>
<p><strong>Example</strong>:<br />
<img src="http://bavotasan.com/wp-content/uploads/2010/04/jnice_example.jpg" alt="" title="jnice_example" width="392" height="270" class="alignleft size-full wp-image-1901" />
</div>
<div class="sections">
<h2>jQuery FormOne</h2>
<p><img src="http://bavotasan.com/wp-content/uploads/2010/04/formone.jpg" alt="" title="formone" width="560" height="163" class="alignleft size-full wp-image-1934" /><br />
jQuery FormOne (aka JQF1) claims to be the most complete form styling plugin and it does seem to cover all the bases.<br />
<a href="http://www.azurem.com/jqf1/">http://www.azurem.com/jqf1/</a></p>
<p><strong>Example</strong>:<br />
<img src="http://bavotasan.com/wp-content/uploads/2010/04/formone_example.jpg" alt="" title="formone_example" width="560" height="978" class="alignleft size-full wp-image-1936" />
</div>
<div class="sections">
<h2>CRIR</h2>
<p><img src="http://bavotasan.com/wp-content/uploads/2010/04/crir.jpg" alt="" title="crir" width="560" height="163" class="alignleft size-full wp-image-1908" /><br />
CRIR styles only radio buttons and checkboxes. It does a cool job of it but you will still need to use CSS to style other elements of your form.<br />
<a href="http://www.chriserwin.com/scripts/crir/index.php">http://www.chriserwin.com/scripts/crir/index.php</a></p>
<p><strong>Example</strong>:<br />
<img src="http://bavotasan.com/wp-content/uploads/2010/04/crir_example.jpg" alt="" title="crir_example" width="404" height="363" class="alignleft size-full wp-image-1905" />
</div>
<div class="sections">
<h2>jQuery Checkbox</h2>
<p><img src="http://bavotasan.com/wp-content/uploads/2010/04/checkbox.jpg" alt="" title="checkbox" width="560" height="163" class="alignleft size-full wp-image-1911" /><br />
jQuery Checkbox was designed to replace the default checkboxes with super awesome switches. It also works with radio buttons.<br />
<a href="http://widowmaker.kiev.ua/checkbox/">http://widowmaker.kiev.ua/checkbox/</a></p>
<p><strong>Example</strong>:<br />
<img src="http://bavotasan.com/wp-content/uploads/2010/04/checkbox_example.jpg" alt="" title="checkbox_example" width="349" height="98" class="alignleft size-full wp-image-1912" />
</div>
<div class="sections">
<h2>File Style</h2>
<p><img src="http://bavotasan.com/wp-content/uploads/2010/04/filestyle.jpg" alt="" title="filestyle" width="560" height="163" class="alignleft size-full wp-image-1938" /><br />
File Style allows you to choose an image to replace the default browse button when using a file input field.<br />
<a href="http://www.appelsiini.net/projects/filestyle">http://www.appelsiini.net/projects/filestyle</a></p>
<p><strong>Example</strong>:<br />
<img src="http://bavotasan.com/wp-content/uploads/2010/04/filestyle_example.jpg" alt="" title="filestyle_example" width="560" height="138" class="alignleft size-full wp-image-1939" />
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2010/8-jquery-plugins-improve-forms-look/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>10 Great Free Mac Apps for Web Developers</title>
		<link>http://bavotasan.com/2009/10-great-free-mac-apps-for-web-developers/</link>
		<comments>http://bavotasan.com/2009/10-great-free-mac-apps-for-web-developers/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 21:06:15 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[environment]]></category>
		<category><![CDATA[everything]]></category>
		<category><![CDATA[Files]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[mac man]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[purpose]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[VirtualBox]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[web developers]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[zip]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=1504</guid>
		<description><![CDATA[I have been a Mac man for almost ten years now, and though many Web developers swear to working on a PC, I find my Mac has everything I need to develop, design and program Web sites. Luckily there are tons of great free apps available to help any developer work more efficiently on their [...]]]></description>
			<content:encoded><![CDATA[<p>I have been a Mac man for almost ten years now, and though many Web developers swear to working on a PC, I find my Mac has everything I need to develop, design and program Web sites. Luckily there are tons of great free apps available to help any developer work more efficiently on their Mac.<br />
<span id="more-1504"></span><br />
Here is a list of 10 great free Mac apps for Web developers that I use:</p>
<div class="lists">
<div class="sections">
<h2>TextWrangler</h2>
<p><img src="http://bavotasan.com/wp-content/uploads/2009/11/textwrangler.jpg" alt="textwrangler" title="textwrangler" width="560" height="163" class="alignleft size-full wp-image-1505" /><br />
TextWrangler is the powerful general purpose text editor with some great features. Whether you are working with HTML, CSS, PHP or any other Web programming language, TextWrangler has everything you need to easily edit your code.<br />
<a href="http://www.barebones.com/products/textwrangler/index.html">http://www.barebones.com/products/textwrangler/index.html</a>
</div>
<div class="sections">
<h2>MAMP</h2>
<p><img src="http://bavotasan.com/wp-content/uploads/2009/11/mamp.jpg" alt="mamp" title="mamp" width="560" height="163" class="alignleft size-full wp-image-1506" /><br />
MAMP installs Apache, Mysql and PHP on your Mac to create a fully functioning Web environment which will allow you to test all aspects of your Web site locally. It&#8217;s smart to have an environment to test and work with offline before making your changed on your live site.<br />
<a href="http://www.mamp.info/en/mamp/index.html">http://www.mamp.info/en/mamp/index.html</a>
</div>
<div class="sections">
<h2>Paparazzi!</h2>
<p><img src="http://bavotasan.com/wp-content/uploads/2009/11/paprazzi.jpg" alt="paprazzi" title="paprazzi" width="560" height="163" class="alignleft size-full wp-image-1507" /><br />
Paparazzi! is a small utility for Mac OS X that takes screen shots of Web pages. This is helpful for creating your portfolio or sending screen shots to clients.<br />
<a href="http://derailer.org/paparazzi/">http://derailer.org/paparazzi/</a>
</div>
<div class="sections">
<h2>YemuZip</h2>
<p><img src="http://bavotasan.com/wp-content/uploads/2009/11/yemuzip.jpg" alt="yemuzip" title="yemuzip" width="560" height="163" class="alignleft size-full wp-image-1509" /><br />
YemuZip is an easy-to-use application for making zip files. Just drag, drop, name your zip file and you&#8217;re done. The native Mac file compressor utility adds Mac-specific info to zip files that, when extracted on a PC, looks like garbage.<br />
<a href="http://www.yellowmug.com/yemuzip/">http://www.yellowmug.com/yemuzip/</a>
</div>
<div class="sections">
<h2>VirtualBox</h2>
<p><img src="http://bavotasan.com/wp-content/uploads/2009/11/virtualbox.jpg" alt="virtualbox" title="virtualbox" width="560" height="163" class="alignleft size-full wp-image-1510" /><br />
VirtualBox is a general-purpose full virtualizer for x86 hardware that allows Mac user to load Windows software on their desktop. <a href="http://bavotasan.com/tutorials/creating-an-internet-explorer-testing-environment-on-a-mac/">Creating an IE testing environment on your Mac</a> is pretty simple using VirtualBox.<br />
<a href="http://www.virtualbox.org/">http://www.virtualbox.org/</a>
</div>
<div class="sections">
<h2>Skype</h2>
<p><img src="http://bavotasan.com/wp-content/uploads/2009/11/skype.jpg" alt="skype" title="skype" width="560" height="163" class="alignleft size-full wp-image-1511" /><br />
Everyone probably already uses this, and if you don&#8217;t, you should. Skype is great to communicate with clients from around the globe. Skype to Skype is free for instant messaging and calls.<br />
<a href="http://www.skype.com/">http://www.skype.com/</a>
</div>
<div class="sections">
<h2>GIMP</h2>
<p><img src="http://bavotasan.com/wp-content/uploads/2009/11/gimp.jpg" alt="gimp" title="gimp" width="560" height="163" class="alignleft size-full wp-image-1512" /><br />
GIMP is an open source versatile graphics manipulation package similar to Adobe&#8217;s Photoshop, but it won&#8217;t put you in the poor house. It may not be as robust but GIMP has some amazing features and who can beat the price.<br />
<a href="http://www.gimp.org/">http://www.gimp.org/</a>
</div>
<div class="sections">
<h2>Cyberduck</h2>
<p><img src="http://bavotasan.com/wp-content/uploads/2009/11/cyberduck.jpg" alt="cyberduck" title="cyberduck" width="560" height="163" class="alignleft size-full wp-image-1513" /><br />
Cyberduck is an open source FTP, SFTP, WebDAV, Cloud Files and Amazon S3 browser for the Mac. It features an easy to use interface with quickly accessible bookmarks.<br />
<a href="http://cyberduck.ch/">http://cyberduck.ch/</a>
</div>
<div class="sections">
<h2>SvnX</h2>
<p><img src="http://bavotasan.com/wp-content/uploads/2009/11/svnx.jpg" alt="svnx" title="svnx" width="560" height="163" class="alignleft size-full wp-image-1515" /><br />
SvnX is an open source GUI for most features of the svn client binary. It allows you to browse your working copies, spot changes and operate on them but also to browse logs and revisions of your repositories.<br />
<a href="http://www.lachoseinteractive.net/en/community/subversion/svnx/features/">http://www.lachoseinteractive.net/en/community/subversion/svnx/features/</a>
</div>
<div class="sections">
<h2>Sequel Pro</h2>
<p><img src="http://bavotasan.com/wp-content/uploads/2009/11/sequelpro.jpg" alt="sequelpro" title="sequelpro" width="560" height="163" class="alignleft size-full wp-image-1521" /><br />
Sequel Pro is a fast, easy-to-use Mac database management application for working with MySQL databases.<br />
<a href="http://www.sequelpro.com/">http://www.sequelpro.com/</a>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/10-great-free-mac-apps-for-web-developers/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Display a List of Upcoming Posts in WordPress</title>
		<link>http://bavotasan.com/2009/display-a-list-of-upcoming-posts-in-wordpress/</link>
		<comments>http://bavotasan.com/2009/display-a-list-of-upcoming-posts-in-wordpress/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 05:10:51 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[ability]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Creating]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[future]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[Sidebar]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Wp]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=1480</guid>
		<description><![CDATA[When you have completed a post in WordPress, you have the ability to save it as a draft, publish it immediately or schedule a future date when it will be published automatically. This is extremely helpful if you want to plan ahead or if you use your WP site for events. Creating a simple list [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://bavotasan.com/wp-content/uploads/2009/11/wordpress-logo-shine.jpg" alt="wordpress-logo-shine" title="wordpress-logo-shine" width="200" height="150" class="alignright size-full wp-image-1482" />When you have completed a post in WordPress, you have the ability to save it as a draft, publish it immediately or schedule a future date when it will be published automatically. This is extremely helpful if you want to plan ahead or if you use your WP site for events. Creating a simple list of upcoming posts lets your visitors know what they can look forward to and is pretty simple to do.<br />
<span id="more-1480"></span><br />
The following code can be placed in your sidebar on within any template.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$futurePosts</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$futurePosts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'showposts=5&amp;post_status=future&amp;order=ASC'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$futurePosts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$futurePosts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;ul&gt;
&lt;li&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;br /&gt;&lt;small&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_time<span style="color: #009900;">&#40;</span>get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'date_format'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/small&gt;&lt;/li&gt;
&lt;/ul&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">else</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;ul&gt;
 &lt;li&gt;No upcoming events.&lt;/li&gt;
&lt;/ul&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

<p>If you want to only display future posts from a specific category, you can add a <code>cat=$id</code> to the query like so:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$futurePosts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'showposts=5&amp;post_status=future&amp;order=ASC&amp;cat=12'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div>

<p>Be sure to change the &#8220;12&#8243; to the category ID.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/display-a-list-of-upcoming-posts-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Display Random Posts in WordPress</title>
		<link>http://bavotasan.com/2009/display-random-posts-in-wordpress/</link>
		<comments>http://bavotasan.com/2009/display-random-posts-in-wordpress/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 17:16:23 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[bit]]></category>
		<category><![CDATA[cat]]></category>
		<category><![CDATA[category]]></category>
		<category><![CDATA[category id]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Display]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[Little Bit]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[page]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=1384</guid>
		<description><![CDATA[I am working on a new WordPress site and I wanted to display a selection of random posts at the bottom of every page. It is pretty simple to do, but I also wanted to make sure that on single post pages, the current post would be excluded. That took a little bit more figuring [...]]]></description>
			<content:encoded><![CDATA[<p>I am working on a new WordPress site and I wanted to display a selection of random posts at the bottom of every page. It is pretty simple to do, but I also wanted to make sure that on single post pages, the current post would be excluded. That took a little bit more figuring out but I got it working.<br />
<span id="more-1384"></span><br />
Here is a quick piece of code to insert into your WordPress templates so that you can display a list of random posts, excluding the current post that is displayed.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$postid</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">'orderby'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'rand'</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'showposts'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'post__not_in'</span><span style="color: #339933;">=&gt;</span>array<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postid</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
query_posts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;ul&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;li&gt;&lt;a href=&quot;'</span><span style="color: #339933;">.</span>get_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; title=&quot;'</span><span style="color: #339933;">.</span>the_title<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">.</span>the_title<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/a&gt;&lt;/li&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/ul&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>You can always change the number of random posts displayed by increasing or decreasing the &#8216;showposts&#8217; variable. You can also make it category specific by adding a <code>'cat'=>24,</code> to the $args array, where &#8217;24&#8242; is the category ID.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/display-random-posts-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Get Familiar with HTML 5</title>
		<link>http://bavotasan.com/2009/get-familiar-with-html-5/</link>
		<comments>http://bavotasan.com/2009/get-familiar-with-html-5/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 14:19:26 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[APIs]]></category>
		<category><![CDATA[direction]]></category>
		<category><![CDATA[future]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[lot]]></category>
		<category><![CDATA[magazine]]></category>
		<category><![CDATA[preview]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[right direction]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[web programming]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=923</guid>
		<description><![CDATA[If you work on the web you have probably heard about HTML 5. It is the next evolutionary step in web programming and the sooner you familiarize yourself with it the better. There is a lot going on in HTML 5 and instead of getting into it myself, I think I should just suggest a [...]]]></description>
			<content:encoded><![CDATA[<p>If you work on the web you have probably heard about HTML 5. It is the next evolutionary step in web programming and the sooner you familiarize yourself with it the better.</p>
<p>There is a lot going on in HTML 5 and instead of getting into it myself, I think I should just suggest a few articles I have come across to steer you all in the right direction.<br />
<span id="more-923"></span><br />
<a href="http://dev.w3.org/html5/spec/Overview.html">WC3 &#8211; A vocabulary and associated APIs for HTML and XHTML</a><br />
<a href="http://www.smashingmagazine.com/2009/07/16/html5-and-the-future-of-the-web/">Smashing Magazine &#8211; HTML 5 and the Future of the Web</a><br />
<a href="http://www.alistapart.com/articles/previewofhtml5">A List Apart &#8211; A Preview of HTML 5</a></p>
<p>If you knew nothing about it before, checking out these articles will fill your mind with so much HTML 5 your eyes will bulge.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/get-familiar-with-html-5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Securing Your Site&#8217;s Directories</title>
		<link>http://bavotasan.com/2009/securing-your-sites-directories/</link>
		<comments>http://bavotasan.com/2009/securing-your-sites-directories/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 16:51:22 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[com]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[Directory]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[folder]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[page]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[Upload]]></category>
		<category><![CDATA[way]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=741</guid>
		<description><![CDATA[If you store files or images in a folder called &#8220;images&#8221;, and people enter www.yoursite.com/images as a URL, they will see a list of all the files you have in that directory. A quick way to solve this is to create an empty index.html or index.php file and upload it to the directory. This will [...]]]></description>
			<content:encoded><![CDATA[<p>If you store files or images in a folder called &#8220;images&#8221;, and people enter <em>www.yoursite.com/images</em> as a URL, they will see a list of all the files you have in that directory. A quick way to solve this is to create an empty index.html or index.php file and upload it to the directory. This will load an empty page instead of showing a content list.<br />
<span id="more-741"></span><br />
Another way of doing this is by modifying (or creating) a .htaccess file. Just place:</p>
<pre name="code" class="php">
Options -indexes
</pre>
<p>in your .htaccess file and it will do the same thing as adding an index.html file to your folder.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/securing-your-sites-directories/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Remove wp_list_pages() Links for Parent Pages</title>
		<link>http://bavotasan.com/2009/how-to-remove-the-links-to-parent-pages-in-the-wordpress-page-list/</link>
		<comments>http://bavotasan.com/2009/how-to-remove-the-links-to-parent-pages-in-the-wordpress-page-list/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 17:48:53 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[call]]></category>
		<category><![CDATA[Creating]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[Lt]]></category>
		<category><![CDATA[page]]></category>
		<category><![CDATA[Pages]]></category>
		<category><![CDATA[parent]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[Remove]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[way]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Wp]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=674</guid>
		<description><![CDATA[Creating a page list in WordPress is super easy. All it takes is one function call: &#60;?php wp_list_pages(); ?&#62;. The only problem with the list is if you have sub-pages categorized under pages that you only want to use as a way to organize your pages. Your parents pages are still linked to in the [...]]]></description>
			<content:encoded><![CDATA[<p>Creating a page list in WordPress is super easy. All it takes is one function call: <code>&lt;?php wp_list_pages(); ?&gt;</code>. The only problem with the list is if you have sub-pages categorized under pages that you only want to use as a way to organize your pages. Your parents pages are still linked to in the list but most likely they will be empty. I decided to create a quick function to solve this problem.<br />
<span id="more-674"></span><br />
Just place this in your theme&#8217;s functions.php file.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> removeParentLinks<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$pages</span> <span style="color: #339933;">=</span> wp_list_pages<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'echo=0&amp;amp;title_li='</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;/li&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pages</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pages</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strstr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&lt;ul&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$page</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;ul&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$page</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$page</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/\&lt;a(.*)\&gt;/'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$page</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #000088;">$page</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: #000088;">$page</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/\&lt;a(.*)\&gt;/'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #000088;">$page</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: #009900;">&#125;</span>
<span style="color: #000088;">$page</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;ul&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$pages</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$count</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$page</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$count</span><span style="color: #339933;">++;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$pages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;/li&gt;'</span><span style="color: #339933;">,</span><span style="color: #000088;">$pages</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$pages</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

<p>Now just replace your <code>wp_list_pages();</code> function with <code>removeParentLinks();</code> and away you go.</p>
<p>NOTE: This only works for page lists that are three levels deep or less.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/how-to-remove-the-links-to-parent-pages-in-the-wordpress-page-list/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
	</channel>
</rss>

