<?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>SoulSizzle Design</title>
	<atom:link href="http://soulsizzle.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://soulsizzle.com</link>
	<description>Music To Your Eyes</description>
	<lastBuildDate>Fri, 20 Jan 2012 10:15:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>MashUp Monthly</title>
		<link>http://soulsizzle.com/projects/mashup-monthly/</link>
		<comments>http://soulsizzle.com/projects/mashup-monthly/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 10:08:52 +0000</pubDate>
		<dc:creator>soulsizzle</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://soulsizzle.com/?p=318</guid>
		<description><![CDATA[The second Saturday of every month, FourSee Entertainment brings the local music scene together for a rare convergence of styles. Rock, Hip Hop, Soul, Jazz, Electronic, and just about anything else you can think of is represented. We were able to create an identity and flyer design that appeals to as wide of a range [...]]]></description>
			<content:encoded><![CDATA[<p>The second Saturday of every month, FourSee Entertainment brings the local music scene together for a rare convergence of styles. Rock, Hip Hop, Soul, Jazz, Electronic, and just about anything else you can think of is represented. We were able to create an identity and flyer design that appeals to as wide of a range of people as their shows do. Every month, the flyer adopts a new color scheme to keep it fresh but keeps its general feel to maintain identity.</p>
]]></content:encoded>
			<wfw:commentRss>http://soulsizzle.com/projects/mashup-monthly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PlatinumEarth.com</title>
		<link>http://soulsizzle.com/projects/platinumearth/</link>
		<comments>http://soulsizzle.com/projects/platinumearth/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 09:48:43 +0000</pubDate>
		<dc:creator>soulsizzle</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://soulsizzle.com/?p=313</guid>
		<description><![CDATA[Platinum Earth, specialists in eco-friendly construction, know that you don&#8217;t have to be a hemp-wearing, jam band-loving hippie to want to protect the enviornment. So when they asked for a forward-thinking website that reflected their work, that&#8217;s exactly what they got. PlatinumEarth.com is clean but full of unique character, a perfect compliment to what they [...]]]></description>
			<content:encoded><![CDATA[<p>Platinum Earth, specialists in eco-friendly construction, know that you don&#8217;t have to be a hemp-wearing, jam band-loving hippie to want to protect the enviornment. So when they asked for a forward-thinking website that reflected their work, that&#8217;s exactly what they got. <a title="Platinum Earth" href="http://www.platinumearth.com">PlatinumEarth.com</a> is clean but full of unique character, a perfect compliment to what they do.</p>
]]></content:encoded>
			<wfw:commentRss>http://soulsizzle.com/projects/platinumearth/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create an Ajax Sorter for WordPress Custom Post Types</title>
		<link>http://soulsizzle.com/jquery/create-an-ajax-sorter-for-wordpress-custom-post-types/</link>
		<comments>http://soulsizzle.com/jquery/create-an-ajax-sorter-for-wordpress-custom-post-types/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 06:43:27 +0000</pubDate>
		<dc:creator>soulsizzle</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://soulsizzle.com/?p=283</guid>
		<description><![CDATA[Ordering custom posts is a generally a drawn-out process of editing the menu order field, post by post. Today, we will make the process many times easier and quicker by using jQuery and a handful of WordPress hooks to create a drag-and-drop solution. The Set-Up This tutorial covers a couple semi-advanced topics. I will, therefore, [...]]]></description>
			<content:encoded><![CDATA[<p>Ordering custom posts is a generally a drawn-out process of editing the <code>menu order</code> field, post by post. Today, we will make the process many times easier and quicker by using jQuery and a handful of WordPress hooks to create a drag-and-drop solution.<br />
<span id="more-283"></span></p>
<h3>The Set-Up</h3>
<p>This tutorial covers a couple semi-advanced topics. I will, therefore, assume you have a firm grasp of PHP, JavaScript, CSS, and WordPress actions. Because of this, I will not going in depth at every step but have made an attempt to reference blog posts and codex articles that may be of help. Despite this lack of depth, you should be able to copy and paste the code and adapt to your own use without much trouble.</p>
<p>One of the best ways to cut down on development time in your projects is to create reusable code. In order to achieve this goal, we will keep all of our PHP, CSS, and JavaScript code in separate files to be easily ported from project to project. I generally keep code of this nature in a <code>/library</code> sub-directory underneath my theme folders.</p>
<p>We will begin by defining our custom post type. In this example, will be creating and working with a <code>Video</code> custom post type. There are numerous other tutorials on the net explaining this process, so I will not cover it in depth. I recommend you read <a href="http://net.tutsplus.com/tutorials/wordpress/rock-solid-wordpress-3-0-themes-using-custom-post-types/">this post</a> over at NetTuts to get started. The code that defines our custom post type is below.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Register Video custom post type
 *
 * @return void
 * @author Soul
 **/</span>
<span style="color: #000000; font-weight: bold;">function</span> soulsizzle_videos_register<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$labels</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	    <span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> _x<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Videos'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post type general name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'singular_name'</span> <span style="color: #339933;">=&gt;</span> _x<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Video'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post type singular name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'add_new'</span> <span style="color: #339933;">=&gt;</span> _x<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Add New'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'release'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'add_new_item'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Add New Video'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'edit_item'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Edit Video'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'new_item'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'New Video'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'view_item'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'View Video'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'search_items'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Search Videos'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'not_found'</span> <span style="color: #339933;">=&gt;</span>  __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'No videos found'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'not_found_in_trash'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'No videos found in Trash'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> 
	    <span style="color: #0000ff;">'parent_item_colon'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span>
	  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<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;">'labels'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$labels</span><span style="color: #339933;">,</span>
    	<span style="color: #0000ff;">'public'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
    	<span style="color: #0000ff;">'show_ui'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
    	<span style="color: #0000ff;">'capability_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span>
    	<span style="color: #0000ff;">'hierarchical'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span>
    	<span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
    	<span style="color: #0000ff;">'supports'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'editor'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'comments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    	<span style="color: #0000ff;">'menu_position'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">,</span>
    	<span style="color: #0000ff;">'menu_icon'</span> <span style="color: #339933;">=&gt;</span> get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/images/menu-videos.png'</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	register_post_type<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'video'</span> <span style="color: #339933;">,</span> <span style="color: #000088;">$args</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'soulsizzle_videos_register'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>As stated above, it is best to keep this in a separate file, so it may be reused again later in other projects. I recomend you create a <code>videos.php</code> file in the <code>library</code> folder underneath your theme directory, and place this and any additional PHP code in it. Then, be sure to include it in your theme by referencing it in the <code>functions.php</code> file as so:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'library/video.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Creating the Sort Menu</h3>
<p>We will now create a <code>Sort</code> sub-menu item that will appear underneath the menu for our Video post type we defined above.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Enable Sort menu
 *
 * @return void
 * @author Soul
 **/</span>
<span style="color: #000000; font-weight: bold;">function</span> soulsizzle_enable_video_sort<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    add_submenu_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'edit.php?post_type=video'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Sort Videos'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Sort'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'edit_posts'</span><span style="color: #339933;">,</span> <span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'soulsizzle_sort_videos'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_menu'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'soulsizzle_enable_video_sort'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Display Sort admin
 *
 * @return void
 * @author Soul
 **/</span>
<span style="color: #000000; font-weight: bold;">function</span> soulsizzle_sort_videos<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$videos</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: #0000ff;">'post_type=video&amp;posts_per_page=-1&amp;orderby=menu_order&amp;order=ASC'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;div class=&quot;wrap&quot;&gt;
	&lt;h3&gt;Sort Videos &lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/wp-admin/images/loading.gif&quot; id=&quot;loading-animation&quot; /&gt;&lt;/h3&gt;
	&lt;ul id=&quot;video-list&quot;&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$videos</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: #000088;">$videos</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><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;li id=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_id<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>&quot;&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;/li&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: #000000; font-weight: bold;">?&gt;</span>
	&lt;/div&gt;&lt;!-- End div#wrap //--&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The first function simply adds a submenu underneath the Video menu using WordPress&#8217;s <a href="http://codex.wordpress.org/Adding_Administration_Menus#Using_add_submenu_page">add_submenu_page()</a>. It is then enabled using <a href="http://codex.wordpress.org/Function_Reference/add_action">add_action()</a>.</p>
<p>The second function is what we told WordPress to call for the sub-menu we defined above. It begins by getting a list of all the posts with type <code>video</code>. By setting <code>posts_per_page</code> to -1, we are telling WordPress to return all of them.</p>
<p>We then create a unordered list with an ID of <code>video-list</code>. Finally, we loop through all the videos and output them as list items. The important thing to note here is that we are setting the ID of the list item to the ID of the post. This will be important later.</p>
<p>Additionally, we placed a reference to <code>loading.gif</code> in the page&#8217;s header. This file is included with WordPress and will be used to let users know when they are waiting on AJAX actions to complete.</p>
<h3>Styling the List</h3>
<p>If you click on the <code>Sort</code> menu item now, it should list all our videos. However, it doesn&#8217;t exactly look pretty. Let&#8217;s work on that. Begin by telling WordPress to queue up our CSS file, which we will create in a moment, by adding the following to our <code>videos.php</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Queue up administration CSS
 *
 * @return void
 * @author Soul
 **/</span>
<span style="color: #000000; font-weight: bold;">function</span> soulsizzle_videos_print_styles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$pagenow</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$pages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'edit.php'</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;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pagenow</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pages</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		wp_enqueue_style<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'soulsizzle_videos'</span><span style="color: #339933;">,</span> get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/library/videos.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'admin_print_styles'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'soulsizzle_videos_print_styles'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The appearence of our list is going to be somewhat of a personal preference. However, by putting the following in a <code>video.css</code> file in the <code>/library</code> directory, you will have something that is simple but meshes well with the WordPress UI.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#video-list</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #cc00cc;">#video-list</span> li <span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>	
		<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">50%</span><span style="color: #00AA00;">;</span>	
		<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#f0f0f0</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* for non-css3 browsers */</span>
		filter<span style="color: #00AA00;">:</span> progid<span style="color: #3333ff;">:DXImageTransform</span><span style="color: #6666ff;">.Microsoft</span>.gradient<span style="color: #00AA00;">&#40;</span>startColorstr<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'#f7f7f7'</span><span style="color: #00AA00;">,</span> endColorstr<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'#e7e7e7'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* for IE */</span>
		<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -webkit-gradient<span style="color: #00AA00;">&#40;</span>linear<span style="color: #00AA00;">,</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">,</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> from<span style="color: #00AA00;">&#40;</span><span style="color: #cc00cc;">#f7f7f7</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> to<span style="color: #00AA00;">&#40;</span><span style="color: #cc00cc;">#e7e7e7</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* for webkit browsers */</span>
		<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -moz-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">,</span>  <span style="color: #cc00cc;">#f7f7f7</span><span style="color: #00AA00;">,</span>  <span style="color: #cc00cc;">#e7e7e7</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* for firefox 3.6+ */</span>
		<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> move<span style="color: #00AA00;">;</span>
&nbsp;
		<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;">#ddd</span><span style="color: #00AA00;">;</span>
		border-raidus<span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
		-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
		-webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#loading-animation</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<h3>The JavaScript</h3>
<p>Thanks to the power of jQuery, which is automatically included in a WordPress install, we can do powerful DOM manipulation and AJAX with very little code. We will be using jQuery to allow our list items to be sorted by drag-and-drop and automatically updating the menu order of our posts each time the order of the list is changed. Let&#8217;s begin by enabling the necessary JavaScript files. We will need to enable jQuery UI&#8217;s <a href="http://jqueryui.com/demos/sortable/">Sortable</a> plugin to handle the drag-and-drop functionality. Additionally, we will need to create and enable our own JavaScript file to handle the AJAX and tell Sortable what to do. Place the following in your <code>videos.php</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Queue up administration JavaScript file
 *
 * @return void
 * @author Soul
 **/</span>
<span style="color: #000000; font-weight: bold;">function</span> soulsizzle_videos_print_scripts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$pagenow</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$pages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'edit.php'</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;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pagenow</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pages</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery-ui-sortable'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'soulsizzle_videos'</span><span style="color: #339933;">,</span> get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/library/videos.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'admin_print_scripts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'soulsizzle_videos_print_scripts'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The above works just like enable our CSS did above. Place the following in <code>video.js</code> in the <code>/library</code> folder.</p>

<div class="wp_syntax"><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>		
	<span style="color: #003366; font-weight: bold;">var</span> videoList <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#video-list'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	videoList.<span style="color: #660066;">sortable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
		update<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #339933;">,</span> ui<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#loading-animation'</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> <span style="color: #006600; font-style: italic;">// Show the animate loading gif while waiting</span>
&nbsp;
			opts <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
				url<span style="color: #339933;">:</span> ajaxurl<span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// ajaxurl is defined by WordPress and points to /wp-admin/admin-ajax.php</span>
				type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'POST'</span><span style="color: #339933;">,</span>
				async<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
				cache<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span>
				dataType<span style="color: #339933;">:</span> <span style="color: #3366CC;">'json'</span><span style="color: #339933;">,</span>
				data<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
					action<span style="color: #339933;">:</span> <span style="color: #3366CC;">'video_sort'</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// Tell WordPress how to handle this ajax request</span>
					order<span style="color: #339933;">:</span> videoList.<span style="color: #660066;">sortable</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'toArray'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// Passes ID's of list items in	1,3,2 format</span>
				<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
				success<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>
					$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#loading-animation'</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> <span style="color: #006600; font-style: italic;">// Hide the loading animation</span>
					<span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span> 
				<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
				error<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>xhr<span style="color: #339933;">,</span>textStatus<span style="color: #339933;">,</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  <span style="color: #006600; font-style: italic;">// This can be expanded to provide more information</span>
					<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'There was an error saving the updates'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#loading-animation'</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> <span style="color: #006600; font-style: italic;">// Hide the loading animation</span>
					<span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span> 
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
			$.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span>opts<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The code above tells jQuery UI&#8217;s Sortable plug-in that the unordered-list with the ID <code>#video-list</code> should be sortable. We also tell Sortable that everytime the user changes the order of the list items, it should preform the function assigned to the <code>update</code> option. Most of the function should be self-explanatory. If you have any questions, be sure to reference jQuery&#8217;s documentation on <a href="http://api.jquery.com/jQuery.ajax/">.ajax</a>. </p>
<p>The first important thing to note is that we set the <code>url</code> option to <code>ajaxurl</code>. This is defined by WordPress and always points to <code>/wp-admin/admin-ajax.php</code>, which is somewhat of a traffic cop for AJAX requests. By making our request through this file, we will have access to all the functions and variable defined by WordPress when we handle the AJAX request below.</p>
<p>The <code>data</code> option contains the variables that we want to send our PHP AJAX handler. The first variable is <code>action</code> and tells <code>admin-ajax.php</code> how to handle the request. The second variable we are using is one we define ourselves. It is named <code>order</code> and contains a list of ID&#8217;s of our videos in the order they currently our in our list. Calling <code>.sortable('toArray')</code> will create an array of these ID&#8217;s and <code>.toString()</code> will put it in a format that is easy to pass through AJAX.</p>
<h3>Handling the AJAX Request</h3>
<p>We must now create our custom PHP AJAX handler. When using custom handlers, <code>admin-ajax.php</code> will execute an action in the form of <code>wp_ajax_[action]</code> where [action] is the name of the <code>action</code> value we pass in our JavaScript. From that point, it&#8217;s just a matter of assigning a function to that action. Add this last bit of PHP to our <code>videos.php</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> soulsizzle_save_video_order<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// WordPress database class</span>
&nbsp;
	<span style="color: #000088;">$order</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'order'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$counter</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$order</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$video_id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">update</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">posts</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'menu_order'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$counter</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'ID'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$video_id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$counter</span><span style="color: #339933;">++;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_ajax_video_sort'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'soulsizzle_save_video_order'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>If you notice, any variables we sent in our JavaScript as <code>data</code> now exists in the <code>$_POST</code> variable. The above code takes the <code>order</code> value and splits it into an array. In then iterates over each ID, and updates the <code>menu_order</code> column of the <code>posts</code> database table with an increasing value. </p>
<p>After rearranging your list of videos, you should be able to the <code>Videos</code> menu and see these changes reflected. </p>
<h3>Wrap-up</h3>
<p>In only a short amount of code, we were able to create a custom Video post type that is both reusable and goes beyond the basics to make it sortable. Not only do we make it easier on our clients but also on ourselves. We covered a lot of information very quickly, so if you have any questions, feel free to ask in the comments section below. For simplicity&#8217;s sake, I&#8217;ve included the full contents of our <code>videos.php</code> file below.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Register Video custom post type
 *
 * @return void
 * @author Soul
 **/</span>
<span style="color: #000000; font-weight: bold;">function</span> soulsizzle_videos_register<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$labels</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	    <span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> _x<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Videos'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post type general name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'singular_name'</span> <span style="color: #339933;">=&gt;</span> _x<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Video'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post type singular name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'add_new'</span> <span style="color: #339933;">=&gt;</span> _x<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Add New'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'release'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'add_new_item'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Add New Video'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'edit_item'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Edit Video'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'new_item'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'New Video'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'view_item'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'View Video'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'search_items'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Search Videos'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'not_found'</span> <span style="color: #339933;">=&gt;</span>  __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'No videos found'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'not_found_in_trash'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'No videos found in Trash'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> 
	    <span style="color: #0000ff;">'parent_item_colon'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span>
	  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<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;">'labels'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$labels</span><span style="color: #339933;">,</span>
    	<span style="color: #0000ff;">'public'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
    	<span style="color: #0000ff;">'show_ui'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
    	<span style="color: #0000ff;">'capability_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span>
    	<span style="color: #0000ff;">'hierarchical'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span>
    	<span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
    	<span style="color: #0000ff;">'supports'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'editor'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'comments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    	<span style="color: #0000ff;">'menu_position'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">,</span>
    	<span style="color: #0000ff;">'menu_icon'</span> <span style="color: #339933;">=&gt;</span> get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/images/menu-videos.png'</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	register_post_type<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'video'</span> <span style="color: #339933;">,</span> <span style="color: #000088;">$args</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'soulsizzle_videos_register'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Enable Sort menu
 *
 * @return void
 * @author Soul
 **/</span>
<span style="color: #000000; font-weight: bold;">function</span> soulsizzle_enable_video_sort<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    add_submenu_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'edit.php?post_type=video'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Sort Videos'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Sort'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'edit_posts'</span><span style="color: #339933;">,</span> <span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'soulsizzle_sort_videos'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_menu'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'soulsizzle_enable_video_sort'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Display Sort admin
 *
 * @return void
 * @author Soul
 **/</span>
<span style="color: #000000; font-weight: bold;">function</span> soulsizzle_sort_videos<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$videos</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: #0000ff;">'post_type=video&amp;posts_per_page=-1&amp;orderby=menu_order&amp;order=ASC'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;div class=&quot;wrap&quot;&gt;
	&lt;h3&gt;Sort Videos &lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/wp-admin/images/loading.gif&quot; id=&quot;loading-animation&quot; /&gt;&lt;/h3&gt;
	&lt;ul id=&quot;video-list&quot;&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$videos</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: #000088;">$videos</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><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;li id=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_id<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>&quot;&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;/li&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: #000000; font-weight: bold;">?&gt;</span>
	&lt;/div&gt;&lt;!-- End div#wrap //--&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Queue up administration JavaScript file
 *
 * @return void
 * @author Soul
 **/</span>
<span style="color: #000000; font-weight: bold;">function</span> soulsizzle_videos_print_scripts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$pagenow</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$pages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'edit.php'</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;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pagenow</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pages</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery-ui-sortable'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'soulsizzle_videos'</span><span style="color: #339933;">,</span> get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/library/videos.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'admin_print_scripts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'soulsizzle_videos_print_scripts'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Queue up administration CSS
 *
 * @return void
 * @author Soul
 **/</span>
<span style="color: #000000; font-weight: bold;">function</span> soulsizzle_videos_print_styles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$pagenow</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$pages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'edit.php'</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;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pagenow</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pages</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		wp_enqueue_style<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'soulsizzle_videos'</span><span style="color: #339933;">,</span> get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/library/videos.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'admin_print_styles'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'soulsizzle_videos_print_styles'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> soulsizzle_save_video_order<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// WordPress database class</span>
&nbsp;
	<span style="color: #000088;">$order</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'order'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$counter</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$order</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$video_id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">update</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">posts</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'menu_order'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$counter</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'ID'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$video_id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$counter</span><span style="color: #339933;">++;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_ajax_video_sort'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'soulsizzle_save_video_order'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://soulsizzle.com/jquery/create-an-ajax-sorter-for-wordpress-custom-post-types/feed/</wfw:commentRss>
		<slash:comments>45</slash:comments>
		</item>
		<item>
		<title>ItsPerfectTiming.com</title>
		<link>http://soulsizzle.com/projects/itsperfecttiming-com/</link>
		<comments>http://soulsizzle.com/projects/itsperfecttiming-com/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 21:10:48 +0000</pubDate>
		<dc:creator>soulsizzle</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://soulsizzle.com/?p=280</guid>
		<description><![CDATA[Rap cross-over duo Perfect Timing needed a site to promote their music and feed their hungry fans news and media. SoulSizzle design produced a solution that was interactive, easy to maintain, and fit their personality perfectly. Vistit the site at ItsPerfectTiming.com.]]></description>
			<content:encoded><![CDATA[<p>Rap cross-over duo Perfect Timing needed a site to promote their music and feed their hungry fans news and media. SoulSizzle design produced a solution that was interactive, easy to maintain, and fit their personality perfectly. Vistit the site at <a href="http://itsperfecttiming.com/">ItsPerfectTiming.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://soulsizzle.com/projects/itsperfecttiming-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding Additional Image Sizes to WordPress Themes</title>
		<link>http://soulsizzle.com/wordpress/adding-additional-image-sizes-to-wordpress-themes/</link>
		<comments>http://soulsizzle.com/wordpress/adding-additional-image-sizes-to-wordpress-themes/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 21:47:43 +0000</pubDate>
		<dc:creator>soulsizzle</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://soulsizzle.com/?p=262</guid>
		<description><![CDATA[WordPress&#8217;s media management and automatic image resizing make things really simple for the client. Users don&#8217;t have to worry about resizing and compressing images before they upload them. However, when used as a complex CMS system, WordPress&#8217;s Thumbnail, Medium, and Large sizes may not be flexible enough. But fret not, your theme can define additional [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress&#8217;s media management and automatic image resizing make things really simple for the client. Users don&#8217;t have to worry about resizing and compressing images before they upload them. However, when used as a complex CMS system, WordPress&#8217;s Thumbnail, Medium, and Large sizes may not be flexible enough. But fret not, your theme can define additional sizes.<span id="more-262"></span></p>
<h3>Where This May Come In Handy</h3>
<p>Especially with version 3.0&#8242;s new CMS features, WordPress is easily used to manage content beyond the traditional posts and pages. For example, I personally do a lot of work with musicians. While the Thumb, Medium, and Large image sizes may work well in the context of their blog, these may not apply to other types of content. Album covers may be one size and show fliers may be another. Additionally, I may want to make available larger promo photos while still avoiding the 8 megapixel originals that the client may upload. Hence, we need to define a few additional image resolutions for WordPress to generate when uploading new pictures.</p>
<h3>Defining The New Image Sizes</h3>
<p>WordPress includes a simple function for achieving this goal, <code>add_image_size()</code>. It requires 4 parameters to do its job: the size&#8217;s name, width, height, and whether to crop it. As a personal preference, I place these size definitions (along with any other theme setup) in a function that is hooked onto the <code>after_setup_theme</code> action hook. Below is an example that defines two additional sizes. The first would be used in a front page featured news rotator, and the second is a larger size that is served if visitors want to download an image. This, and any additional code shown, goes in your theme&#8217;s functions.php file.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> mytheme_setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	add_image_size<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'featured-thumbnail'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">640</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">320</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	add_image_size<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'x-large'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">800</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">800</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: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'after_setup_theme'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mytheme_setup'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Rather simple, eh? Now when a new image is uploaded into WordPress, a cropped 640&#215;320 version and one that fits within 800&#215;800 dimensions will be created.</p>
<h3>Using The Sizes in Your Theme</h3>
<p>These sizes will not be accessible to the client for insertion into posts and pages. Their strength lies in how they are implemented into your themes. For example, for a recent project I created a front page news rotator that was independent of the blog posts. Therefore, the Thumbnail size was not applicable. So I registered a &#8216;featured-thumbnail&#8217; size similar to above and created a <a href="http://net.tutsplus.com/tutorials/wordpress/rock-solid-wordpress-3-0-themes-using-custom-post-types/">custom post type</a> for managing the news items. Each news item was given a Featured Image in WordPress&#8217;s dashboard. </p>
<p><img src="http://soulsizzle.com/wp-content/uploads/2010/07/featured-image-580x228.jpg" alt="" title="Featured Image" width="580" height="228" class="aligncenter size-large wp-image-263" /></p>
<p>Then it&#8217;s just a matter of using WordPress&#8217;s <code>the_post_thumbnail()</code> function to insert the image in our defined dimensions. Generally, the only parameter you need to pass is the name of our newly defined image size. The resulting code is as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;ul&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #000088;">$featured</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: #0000ff;">&quot;post_type=featured&amp;post_status=publish&quot;</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;">$featured</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: #000088;">$featured</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><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;li&gt;
		<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'featured-thumbnail'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Inserts image with our defined dimensions ?&gt; </span>
		<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;newsDescription&quot;</span><span style="color: #339933;">&gt;</span>
			<span style="color: #339933;">&lt;</span>h3<span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php 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;/h3&gt;
			&lt;p&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<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;/p&gt;
		&lt;/div&gt;
	&lt;/li&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: #000000; font-weight: bold;">?&gt;</span>
&lt;/ul&gt;</pre></div></div>

<h3>Conclusion</h3>
<p>The team of developers behind WordPress are well aware of its evolution from a simple blogging platform to a strong content management system. With the release of version 3.0, managing a wide range of content types has never been easier. Each content type will have its own requirements for display, and being able to define additional image sizes is just one of many tools for meeting those requirements.</p>
]]></content:encoded>
			<wfw:commentRss>http://soulsizzle.com/wordpress/adding-additional-image-sizes-to-wordpress-themes/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>Manage a Boatload of WordPress Sidebars With Help From jQuery</title>
		<link>http://soulsizzle.com/jquery/manage-a-boatload-of-wordpress-sidebars-with-help-from-jquery/</link>
		<comments>http://soulsizzle.com/jquery/manage-a-boatload-of-wordpress-sidebars-with-help-from-jquery/#comments</comments>
		<pubDate>Sun, 30 May 2010 04:39:30 +0000</pubDate>
		<dc:creator>soulsizzle</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://soulsizzle.com/?p=249</guid>
		<description><![CDATA[I recently finished a project that pushed WordPress farther than I have ever before. Essentially, each of the 18 categories was a micro-site with its own styling and two widgetized areas. That means 36 different widgetized sections! When viewing the Widget page in the WordPress Dashboard, the list of widget areas extended quite a bit [...]]]></description>
			<content:encoded><![CDATA[<p>I recently finished a project that pushed WordPress farther than I have ever before. Essentially, each of the 18 categories was a micro-site with its own styling and two widgetized areas. That means 36 different widgetized sections! When viewing the Widget page in the WordPress Dashboard, the list of widget areas extended quite a bit below the fold. This made adding and managing the widgets extremely cumbersome. The obvious solution was to display only one widget area at a time.<span id="more-249"></span></p>
<h3>Fleshing Out The Solution</h3>
<p>Before writing any code, I like to flesh out the basics to my solution on paper. Some simple brainstorming lead me to the following goals:</p>
<ol>
<li>Create an array of all the widget areas available</li>
<li>Hide all the listed widget areas besides the first</li>
<li>Insert into the Widget page a drop-down box containing a list of the widget areas&nbsp;in&nbsp;our&nbsp;array</li>
<li>Whenever a user selects a widget area from the drop-down box, show that one and&nbsp;hide&nbsp;the&nbsp; rest</li>
</ol>
<h3>Loading Our Javascript File</h3>
<p>We&#8217;ll begin by creating a file named <code>widget-admin.js</code>. Save this file somewhere in your theme directory. I prefer to keep all my JavaScript files in the <code>js/</code> sub-directory. We only want this code to be loaded if we are on the Widgets page of the WordPress dashboard. To achieve this, add the following code to your <code>functions.php</code> file.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Custom Admin Sidebar Switcher</span>
<span style="color: #000000; font-weight: bold;">function</span> sidebar_switcher<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$pagenow</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pagenow</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'widgets.php'</span><span style="color: #009900;">&#41;</span>
		wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'fca_admin'</span><span style="color: #339933;">,</span> get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/js/widget-admin.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_print_scripts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'sidebar_switcher'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>By latching onto WordPress&#8217;s <code>admin_print_scripts</code> hook, our <code>sidebar_switcher()</code> function will only be run when we are in the dashboard. The <code>sidebar_switcher()</code> function checks if we are on the Widgets page. If we are, it tells WordPress to queue up our <code>widget-admin.js</code> file.</p>
<h3>Letting jQuery Work It&#8217;s Magic</h3>
<p>The following code goes into the <code>widget-admin.js</code> that we created earlier. The comments should make it self-explanatory.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;document&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>ready<span style="color: #009900;">&#40;</span><span style="color: #000000; 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: #000000; font-weight: bold;">var</span> sidebars <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</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: #666666; font-style: italic;">// Create array to hold our list of widget areas</span>
	<span style="color: #000000; font-weight: bold;">var</span> selectorHTML<span style="color: #339933;">,</span> name<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Declaring variables isn't necessary in JavaScript, but it's good practice</span>
&nbsp;
	jQuery<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.widget-liquid-right .sidebar-name h3'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #990000;">each</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>index<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		name <span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span>this<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>html<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Get the name of each widget area</span>
		name <span style="color: #339933;">=</span> name<span style="color: #339933;">.</span>replace<span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span>\s<span style="color: #339933;">*&lt;</span>span<span style="color: #339933;">&gt;.*&lt;</span>\<span style="color: #339933;">/</span>span<span style="color: #339933;">&gt;/,</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Remove extra &lt;span&gt; block from name</span>
		sidebars<span style="color: #339933;">.</span>push<span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Add the name to our array</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	jQuery<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.widget-liquid-right .widgets-holder-wrap'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>hide<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Hide all the widget areas in list</span>
	jQuery<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.widget-liquid-right .widgets-holder-wrap:first'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>show<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Show the first</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Start &lt;select&gt; block. Position to the right of the &quot;Widgets&quot; heading.</span>
	selectorHTML <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;select id=<span style="color: #000099; font-weight: bold;">\&quot;</span>sidebarSelector<span style="color: #000099; font-weight: bold;">\&quot;</span> style=<span style="color: #000099; font-weight: bold;">\&quot;</span>position: absolute; left: 400px; top: 68px;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #990000;">count</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">var</span> i in sidebars <span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// Add option for each widgetized area</span>
		selectorHTML <span style="color: #339933;">=</span> selectorHTML <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&lt;option value=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">+</span> <span style="color: #990000;">count</span><span style="color: #339933;">++</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span> <span style="color: #339933;">+</span> sidebars<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&lt;/option&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Store the index of the widget area in the 'value' attribute</span>
&nbsp;
	selectorHTML <span style="color: #339933;">=</span> selectorHTML <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&lt;/select&gt;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Close the &lt;select&gt; block</span>
&nbsp;
	jQuery<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'div.wrap'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>append<span style="color: #009900;">&#40;</span>selectorHTML<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Insert it into the DOM</span>
&nbsp;
	jQuery<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#sidebarSelector'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>change<span style="color: #009900;">&#40;</span><span style="color: #000000; 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: #666666; font-style: italic;">// When the user selects something from the select box...</span>
		index <span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span>this<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>val<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Figure out which one they chose</span>
		jQuery<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.widget-liquid-right .widgets-holder-wrap'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>hide<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Hide all the widget areas</span>
		jQuery<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.widget-liquid-right .widgets-holder-wrap:eq('</span> <span style="color: #339933;">+</span> index <span style="color: #339933;">+</span> <span style="color: #0000ff;">')'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>show<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// And show only the corresponding one</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Conclusion</h3>
<p>When pushing WordPress to it&#8217;s limit, it may occasionally be necessary to enhance its user interface. With the power of jQuery and WordPress&#8217;s action and filter hooks, the sky is the limit. </p>
]]></content:encoded>
			<wfw:commentRss>http://soulsizzle.com/jquery/manage-a-boatload-of-wordpress-sidebars-with-help-from-jquery/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Game Over</title>
		<link>http://soulsizzle.com/projects/game-over/</link>
		<comments>http://soulsizzle.com/projects/game-over/#comments</comments>
		<pubDate>Tue, 04 May 2010 02:41:56 +0000</pubDate>
		<dc:creator>soulsizzle</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://soulsizzle.com/?p=236</guid>
		<description><![CDATA[We always welcome the opportunity to reminisce. So we took a time machine back to the eighties for inspiration this promotional flier for Game Over, a hip hop show featuring many of Indianapolis&#8217;s best emcees.]]></description>
			<content:encoded><![CDATA[<p>We always welcome the opportunity to reminisce. So we took a time machine back to the eighties for inspiration this promotional flier for Game Over, a hip hop show featuring many of Indianapolis&#8217;s best emcees.</p>
]]></content:encoded>
			<wfw:commentRss>http://soulsizzle.com/projects/game-over/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Brad Real &#8211; Mumble</title>
		<link>http://soulsizzle.com/projects/brad-real-mumble/</link>
		<comments>http://soulsizzle.com/projects/brad-real-mumble/#comments</comments>
		<pubDate>Tue, 04 May 2010 02:28:06 +0000</pubDate>
		<dc:creator>soulsizzle</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://soulsizzle.com/?p=234</guid>
		<description><![CDATA[Proving that once again, even a free product can benefit from good design. Sometimes, it is hard work to give something away. Brad Real planned on releasing his single &#8220;Mumble&#8221; as a free download in order to help spread his name. Soulsizzle Design produced what you see below, a design ensured to pique interest in [...]]]></description>
			<content:encoded><![CDATA[<p>Proving that once again, even a free product can benefit from good design. Sometimes, it is hard work to give something away. Brad Real planned on releasing his single &#8220;Mumble&#8221; as a free download in order to help spread his name. Soulsizzle Design produced what you see below, a design ensured to pique interest in the song across web, e-mail correspondence, and social networking.</p>
]]></content:encoded>
			<wfw:commentRss>http://soulsizzle.com/projects/brad-real-mumble/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Display a Different Number of Posts in WordPress Searches</title>
		<link>http://soulsizzle.com/wordpress/display-a-different-number-of-posts-in-wordpress-searches/</link>
		<comments>http://soulsizzle.com/wordpress/display-a-different-number-of-posts-in-wordpress-searches/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 02:10:08 +0000</pubDate>
		<dc:creator>soulsizzle</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://soulsizzle.com/?p=217</guid>
		<description><![CDATA[WordPress treats every page/post-listing just about the same. Whether it&#8217;s the homepage, a blog category, search results, or even your average page, the same basic logic is used to generate it. This also means that the same settings, including the number of posts displayed per page, are used across the board. However, this is not [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress treats every page/post-listing just about the same. Whether it&#8217;s the homepage, a blog category, search results, or even your average page, the same basic logic is used to generate it. This also means that the same settings, including the number of posts displayed per page, are used across the board. However, this is not always desirable.<span id="more-217"></span></p>
<blockquote><p>
I have made some changes to the original code that appeared in this article. The new solution is nearly identical to Keith&#8217;s below. Though I did arrive at this solution independently, he does deserve some acknowledgment for beating me to the punch.
</p></blockquote>
<h3>The Goal</h3>
<p>The basic goal of a site search is to find information quickly; however, it is becoming more and more commonplace to see increasingly stylized post listings. In my eyes, this runs the risk of becoming counter-intuitive to this goal. Because of this, it is my personal preference to simplify my search results and to show more results. Because searches rely on the same setting (found in <em>Settings » Reading » Blog pages show at most)</em> as any other WordPress page when determining the number of listings to show, we have to get a little creative in order to show a different am amount.</p>
<h3>How Not to Do It</h3>
<p>Most blog posts or WordPress.org forum posts will recommend using the <code>query_posts()</code> function in order to alter the number of search listings shown. They advise inserting something similar before the loop in your themes search.php.</p>
<p>However, this neglects one important fact. WordPress already runs the query once before it even gets to this query_posts() call. This means that you are essentially doubling the number of database calls WordPress needs to do in order to retrieve the correct number of posts. If an efficient, quickly-loading site is important to you (I know it is to me), this should be a concern. This is even more important with the recent news that Google is now incorporating page-load time into its pagerank algorithm.</p>
<h3>A Better Solution</h3>
<p>The obvious solution is to alter the original query before it is executed. This is made fairly simple with WordPress filters (noticing a common theme in our WordPress-related posts?). Using the <code>pre_get_posts</code> filter, we can change the query parameters before it is translated into an actual MySQL query. Simply insert the following code into the <code>functions.php</code> file of your theme. It&#8217;s so simple, I hope this technique will become more commonplace.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> change_wp_search_size<span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</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: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">is_search</span> <span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// Make sure it is a search page</span>
		<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query_vars</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'posts_per_page'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Change 10 to the number of posts you would like to show</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$query</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Return our modified query variables</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pre_get_posts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'change_wp_search_size'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Hook our custom function onto the request filter</span></pre></div></div>

<p>Any function that is hooked into the <code>pre_get_posts</code> filter will automatically be passed an <a href="http://codex.wordpress.org/Function_Reference/WP_Query">WP_Query</a> Object containing any parameters that intends to use to generate the database query. All we have to do is change the <code>posts_per_page</code> parameter to the number of results we would like to show.</p>
<p>We must first determine if we are even on the search results page. This is as easy as testing to see if <code>$query->is_search</code> is set. Then, it&#8217;s simply a matter of returning our modified query paramaters to WordPress and letting WordPress do it&#8217;s magic. </p>
<h3>A few additional notes</h3>
<p>If you don&#8217;t want to limit the number of posts shown at all, simply set <code>$query->query_varts['posts_per_page']</code> to -1. Also, this technique is not limited to the search page only. You can also test for <code>$query->is_cateogry</code>, <code>$query->is_tag</code>, <code>$query->is_archive</code>, <code>$query->is_date</code>, and etc. And if you want to test for a specific category you can use a conditional statement similar to the following:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query_vars</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cateogry_name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'category_slug'</span><span style="color: #009900;">&#41;</span></pre></div></div>

<h3>The Wrap-up</h3>
<p>Though this solution may contain a few more lines of code than a <code>query_posts()</code> solution, it is still superior for two reasons.</p>
<ol>
<li>It is quicker by nearly halving the number of database calls</li>
<li>We separate logic and presentation as much as possible, which should be a ever-present goal in web programming and design</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://soulsizzle.com/wordpress/display-a-different-number-of-posts-in-wordpress-searches/feed/</wfw:commentRss>
		<slash:comments>64</slash:comments>
		</item>
		<item>
		<title>The Wake-Up</title>
		<link>http://soulsizzle.com/projects/the-wake-up/</link>
		<comments>http://soulsizzle.com/projects/the-wake-up/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 00:36:13 +0000</pubDate>
		<dc:creator>soulsizzle</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://soulsizzle.com/?p=211</guid>
		<description><![CDATA[The design for Sleeper Cell&#8217;s mixtape &#8220;The Wake-Up&#8221; is proof that a small project can still have great design. The DJ-mixed album was created as a promotional tool to be given away for free digitally and in a limited-run physical pressing. Because of this, the budget was limited. However, they were still concerned with sticking [...]]]></description>
			<content:encoded><![CDATA[<p>The design for Sleeper Cell&#8217;s mixtape &#8220;The Wake-Up&#8221; is proof that a small project can still have great design. The DJ-mixed album was created as a promotional tool to be given away for <a href="http://bit.ly/aoyDzG">free digitally</a> and in a limited-run physical pressing. Because of this, the budget was limited. However, they were still concerned with sticking out amongst the slew of hastily-produced mixtapes that flood the internet.</p>
]]></content:encoded>
			<wfw:commentRss>http://soulsizzle.com/projects/the-wake-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

