<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Web Presence Partners</title>
	<atom:link href="http://webpresencepartners.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://webpresencepartners.com</link>
	<description>Vero Beach, Florida Website Design and Development</description>
	<lastBuildDate>Sat, 18 Feb 2012 13:29:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>We&#8217;re at WordCamp Miami!</title>
		<link>http://webpresencepartners.com/2012/02/18/were-at-wordcamp-miami/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=were-at-wordcamp-miami</link>
		<comments>http://webpresencepartners.com/2012/02/18/were-at-wordcamp-miami/#comments</comments>
		<pubDate>Sat, 18 Feb 2012 13:29:14 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://webpresencepartners.com/?p=798</guid>
		<description><![CDATA[We&#8217;re at WordCamp Miami 2012 today! We&#8217;ll be posting a few random thoughts and photos as we go.]]></description>
			<content:encoded><![CDATA[<p><img title="IMG_20120218_075236.jpg" class="alignnone" alt="image" src="http://webpresencepartners.com/wp-content/uploads/2012/02/wpid-IMG_20120218_075236.jpg" /></p>
<p>We&#8217;re at WordCamp Miami 2012 today! We&#8217;ll be posting a few random thoughts and photos as we go.</p>
<p><img title="IMG_20120218_081049.jpg" class="alignnone" alt="image" src="http://webpresencepartners.com/wp-content/uploads/2012/02/wpid-IMG_20120218_081049.jpg" /></p>
]]></content:encoded>
			<wfw:commentRss>http://webpresencepartners.com/2012/02/18/were-at-wordcamp-miami/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The CSS Image Map Generator is Back</title>
		<link>http://webpresencepartners.com/2011/12/29/the-css-image-map-generator-is-back/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-css-image-map-generator-is-back</link>
		<comments>http://webpresencepartners.com/2011/12/29/the-css-image-map-generator-is-back/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 00:44:33 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[For Developers]]></category>

		<guid isPermaLink="false">http://webpresencepartners.com/?p=781</guid>
		<description><![CDATA[After a brief hiatus, our CSS Image Map Generator tool is back online. We took it offline while transitioning to the new site design and are happy to be bringing it back! Access it here. If you haven&#8217;t used it before, it&#8217;s an easy-to-use GUI tool to create CSS-based &#8220;image maps.&#8221; Rather than using the [...]]]></description>
			<content:encoded><![CDATA[<p>After a brief hiatus, our <a title="CSS Image Map Generator" href="http://webpresencepartners.com/tools/css-image-map-generator/">CSS Image Map Generator</a> tool is back online. We took it offline while transitioning to the new site design and are happy to be bringing it back!</p>
<p><a title="CSS Image Map Generator" href="http://webpresencepartners.com/tools/css-image-map-generator/">Access it here</a>.</p>
<p>If you haven&#8217;t used it before, it&#8217;s an easy-to-use GUI tool to create CSS-based &#8220;image maps.&#8221; Rather than using the HTML map and area tags, it uses CSS positioning to achieve a very similar effect by layering HTML anchor (&#8220;a&#8221;) elements over an image.</p>
<p>The interface consists of four tabs (plus a fifth Feedback and Credits tab):</p>
<ol>
<li><strong>Upload Image</strong> &#8211; Upload the image you&#8217;d like to place links on. Once the image is uploaded successfully, you&#8217;ll automatically jump to the next tab.</li>
<li><strong>Visual Editor</strong> &#8211; A nice, drag-and-drop interface that allows you to place your links anywhere on the image. You can move, resize, edit, and delete the link from here. <span class="highlight">Click the Pencil icon and set the link text, title, and URL. Otherwise your link will be pretty pointless!</span></li>
<li><strong>Preview</strong> &#8211; Just as you&#8217;d expect, you can preview your creation here before moving on. If you&#8217;re not happy with your work, you can always click back to the Editor tab and make changes.</li>
<li><strong>Generated Code</strong> &#8211; Provides you with ready-made HTML and CSS code that can be copied and pasted onto your website. <span class="highlight">Be sure to change the path to the image to something that makes sense on your website!</span></li>
</ol>
<p>That&#8217;s all folks. If you use this tool and have some feedback for us, <a title="Get In Touch" href="http://webpresencepartners.com/get-in-touch/">we&#8217;d love to hear it</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://webpresencepartners.com/2011/12/29/the-css-image-map-generator-is-back/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a WordPress Post Meta Widget, Part 2</title>
		<link>http://webpresencepartners.com/2011/12/22/creating-a-wordpress-post-meta-widget-part-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=creating-a-wordpress-post-meta-widget-part-2</link>
		<comments>http://webpresencepartners.com/2011/12/22/creating-a-wordpress-post-meta-widget-part-2/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 21:22:18 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[For Developers]]></category>
		<category><![CDATA[WordPress Development]]></category>

		<guid isPermaLink="false">http://webpresencepartners.com/?p=754</guid>
		<description><![CDATA[This is the final installment of our two part series on building a simple WordPress widget that displays the current post’s meta information. You can see part one here. In this post, we’ll be adding some user-selectable options to our post meta widget. If you’re familiar with the widgets that are included with WordPress, most [...]]]></description>
			<content:encoded><![CDATA[<p>This is the final installment of our two part series on building a simple WordPress widget that displays the current post’s meta information. <a title="Creating a WordPress Post Meta Widget, Part 1" href="http://webpresencepartners.com/2011/12/14/creating-a-wordpress-post-meta-widget-part-1/">You can see part one here</a>.</p>
<p>In this post, we’ll be adding some user-selectable options to our post meta widget. If you’re familiar with the widgets that are included with WordPress, most of them allow you to customize their title as it appears in your blog’s sidebar area. We’ll be adding that option to our widget, as well. In addition, we’re going to add the option to use the current post’s title as our widget title.</p>
<h2>WordPress Functions We’ll Be Using</h2>
<ul>
<li><a href="http://codex.wordpress.org/Function_Reference/get_option">get_option</a></li>
<li><a href="http://codex.wordpress.org/Function_Reference/esc_attr">esc_attr</a></li>
<li><a href="http://codex.wordpress.org/Function_Reference/update_option">update_option</a></li>
<li><a href="http://codex.wordpress.org/Function_Reference/wp_register_widget_control">wp_register_widget_control</a></li>
</ul>
<h2>How It Works</h2>
<p>Creating an options form for our widget (or a “control” function as the WordPress internals call it) is just as simple &#8212; if not simpler &#8212; than creating the widget itself. If you have some experience creating and consuming forms in PHP, this really is a snap.</p>
<p>Your options form is really just a standard HTML form that posts back to itself when the user clicks the save button. So, your control function has to do two things:</p>
<ol>
<li>Save any option values that have been posted to us.</li>
<li>Output the form that allows the user to set option values.</li>
</ol>
<p>Once we have a control function, we just need to let WordPress know about it using wp_register_widget_control and we’re all set.</p>
<h2>The Code</h2>
<p>First, a couple notes regarding this particular implementation: To store the option values for our widget, I’m going to use WordPress’ built-in options database. We’ll be adding two options: my_post_meta_widget_title and my_post_meta_widget_use_post_title. Verbose? Yes. Chances of colliding with another option? Pretty slim.</p>
<p>WordPress is even more hands-off with our control function than it is with our widget function. There are no parameters passed to it, and it does not have any constraints regarding its output.</p>
<p>As mentioned previously, the first thing you’ll want your function to do is check the $_POST array to see if we have new values for our options. If there are new values present, we’ll update the values stored in the database. Let’s take a look at what our function will look like with just that code included:</p>
<pre>&lt;?php
    function my_post_meta_widget_control(){

        if (isset($_POST['my_post_meta_widget_use_post_title'])) {
            $use_post_title = (int) $_POST['my_post_meta_widget_use_post_title'];
            update_option('my_post_meta_widget_use_post_title', $use_post_title);
        }
        if (isset($_POST['my_post_meta_widget_title'])) {
            $widget_title = esc_attr($_POST['my_post_meta_widget_title']);
            update_option('my_post_meta_widget_title', $widget_title);
        }
    }
?&gt;</pre>
<p>Pretty standard PHP so far. Notice, however, that we did use WordPress’ esc_attr function to escape the user-supplied title string, just in case. Notice also that we’re casting my_post_meta_widget_use_post_title to an integer because the form control we’re about to use is a checkbox. That should also take care of any potential strangeness our users might attempt to introduce.</p>
<p>Okay, but what if there were no new values submitted? We need to retrieve the existing values from the database so we can pre-fill the form with our user’s previously selected options or default values if they’ve not made a selection previously. Let’s add that little bit of magic to our function and see what it looks like.</p>
<pre>&lt;?php
    function my_post_meta_widget_control(){

        if (isset($_POST['my_post_meta_widget_use_post_title'])) {
            $use_post_title = (int) $_POST['my_post_meta_widget_use_post_title'];
            update_option('my_post_meta_widget_use_post_title', $use_post_title);
        } <span class="highlight">else {
            $use_post_title = (int) get_option('my_post_meta_widget_use_post_title');
        }</span>
        if (isset($_POST['my_post_meta_widget_title'])) {
            $widget_title = esc_attr($_POST['my_post_meta_widget_title']);
            update_option('my_post_meta_widget_title', $widget_title);
        } <span class="highlight">else {
            $widget_title = get_option('my_post_meta_widget_title');
        }
        $widget_title = ($widget_title) ? $widget_title : 'About This Post';</span>
    }
?&gt;</pre>
<p>Cool. So, if the user gives us new values via $_POST, we write them to the database and use them. Otherwise, we pull the existing values from the database. If we come up empty there, we use a default value for the title. Since the checkbox is just a simple boolean, we don’t bother setting a default.</p>
<p>Side note: If you’re having a little trouble with that last line, I’m using PHP’s ternary operator to assign a default value to the title. <a href="http://php.net/manual/en/language.operators.comparison.php">More information is available on the ternary operator in the official PHP docs</a>.</p>
<p>Now we’ve got all the info we need to show the user an options form, so let’s do that:</p>
<pre>&lt;?php
    function my_post_meta_widget_control(){

        if (isset($_POST['my_post_meta_widget_use_post_title'])) {
            $use_post_title = (int) $_POST['my_post_meta_widget_use_post_title'];
            update_option('my_post_meta_widget_use_post_title', $use_post_title);
        } else {
            $use_post_title = (int) get_option('my_post_meta_widget_use_post_title');
        }
        if (isset($_POST['my_post_meta_widget_title'])) {
            $widget_title = esc_attr($_POST['my_post_meta_widget_title']);
            update_option('my_post_meta_widget_title', $widget_title);
        } else {
            $widget_title = get_option('my_post_meta_widget_title');
        }
        $widget_title = ($widget_title) ? $widget_title : 'About This Post';
<span class="highlight">        ?&gt;
        &lt;p&gt;
            &lt;input name="my_post_meta_widget_use_post_title" type="hidden" value="0" /&gt;
            &lt;input id="my_post_meta_widget_use_post_title" name="my_post_meta_widget_use_post_title" type="checkbox" value="1" &lt;?php if($use_post_title) echo 'checked="checked" '; ?&gt;/&gt;
            &lt;label for="my_post_meta_widget_use_post_title"&gt;Use Post Title as Widget Title&lt;/label&gt;
        &lt;/p&gt;
        &lt;p&gt;
            &lt;label for="my_post_meta_widget_title"&gt;Widget Title&lt;/label&gt;&lt;br /&gt;
            &lt;input id="my_post_meta_widget_title" name="my_post_meta_widget_title" type="text" value="&lt;?php echo $widget_title; ?&gt;" /&gt;
        &lt;/p&gt;
        &lt;?php</span>
    }
?&gt;</pre>
<p>We’re using a pretty standard HTML form laced with a little PHP magic to show the user the values they’ve previously selected (or the defaults.)<br />
If you take a close look at our boolean option (the option we used a checkbox to represent) you’ll notice something a little out of the ordinary: a hidden input with the same name as our checkbox and a value of 0 (zero). A checkbox’s value is only included in a form’s post data if the box is checked; otherwise, nothing about the checkbox is sent. Here, we’re taking advantage of another behavior to substitute a 0 value. If the browser encounters two values for the same named form element, it only includes the last one with the post data. So, if the box is checked, the hidden input’s 0 value is ignored, and the checkbox’s 1 is used. However, if the checkbox is unchecked, it is ignored and the 0 is used.</p>
<p>So, we’ve pulled in our new settings if they’re present, and given the user a form to use to change them. All that’s left is to let WordPress know that all this wonderful code exists! For that, we register our function using wp_register_widget_control, like so:</p>
<pre>&lt;?php
    function my_post_meta_widget_control(){

        if (isset($_POST['my_post_meta_widget_use_post_title'])) {
            $use_post_title = (int) $_POST['my_post_meta_widget_use_post_title'];
            update_option('my_post_meta_widget_use_post_title', $use_post_title);
        } else {
            $use_post_title = (int) get_option('my_post_meta_widget_use_post_title');
        }
        if (isset($_POST['my_post_meta_widget_title'])) {
            $widget_title = esc_attr($_POST['my_post_meta_widget_title']);
            update_option('my_post_meta_widget_title', $widget_title);
        } else {
            $widget_title = get_option('my_post_meta_widget_title');
        }
        $widget_title = ($widget_title) ? $widget_title : 'About This Post';
        ?&gt;
        &lt;p&gt;
            &lt;input name="my_post_meta_widget_use_post_title" type="hidden" value="0" /&gt; &lt;!-- Rails trick : hidden '0' input stacked behind checkbox --&gt;
            &lt;input id="my_post_meta_widget_use_post_title" name="my_post_meta_widget_use_post_title" type="checkbox" value="1" &lt;?php if($use_post_title) echo 'checked="checked" '; ?&gt;/&gt;
            &lt;label for="my_post_meta_widget_use_post_title"&gt;Use Post Title as Widget Title&lt;/label&gt;
        &lt;/p&gt;
        &lt;p&gt;
            &lt;label for="my_post_meta_widget_title"&gt;Widget Title&lt;/label&gt;&lt;br /&gt;
            &lt;input id="my_post_meta_widget_title" name="my_post_meta_widget_title" type="text" value="&lt;?php echo $widget_title; ?&gt;" /&gt;
        &lt;/p&gt;
        &lt;?php
    }
<span class="highlight">    wp_register_widget_control('my_post_meta_widget', 'my Current Post Meta', 'my_post_meta_widget_control');</span>
?&gt;</pre>
<p>Revisiting Our Widget Code and Adding our Options</p>
<p>In part one, we created a function to display our post-meta widget in our blog’s sidebar. Combine that with the code we just wrote, and you’ll get something like this:</p>
<pre>&lt;?php
    <span class="highlight">function my_post_meta_widget($args) {
        if( ! is_singular() ) return;
        extract($args);
        echo $before_widget . $before_title . 'About This Post' . $after_title;
        ?&gt;
        &lt;ul&gt;
            &lt;li class="date"&gt;&lt;?php the_time('F jS, Y'); ?&gt;&lt;/li&gt;
            &lt;li class="author"&gt;By &lt;?php the_author(); ?&gt;&lt;/li&gt;
            &lt;li class="comments"&gt;&lt;?php comments_number(); ?&gt;&lt;/li&gt;
            &lt;li class="categories"&gt;Categories: &lt;?php the_category(', '); ?&gt;&lt;/li&gt;
            &lt;li class="tags"&gt;Tags: &lt;?php the_tags(' ', ', ', ' '); ?&gt;&lt;/li&gt;
        &lt;/ul&gt;
        &lt;?php
        echo $after_widget;
    }
    wp_register_sidebar_widget('my_post_meta_widget_id', 'Post Meta Widget', 'my_post_meta_widget');</span>

    function my_post_meta_widget_control(){

        if (isset($_POST['my_post_meta_widget_use_post_title'])) {
            $use_post_title = (int) $_POST['my_post_meta_widget_use_post_title'];
            update_option('my_post_meta_widget_use_post_title', $use_post_title);
        } else {
            $use_post_title = (int) get_option('my_post_meta_widget_use_post_title');
        }
        if (isset($_POST['my_post_meta_widget_title'])) {
            $widget_title = esc_attr($_POST['my_post_meta_widget_title']);
            update_option('my_post_meta_widget_title', $widget_title);
        } else {
            $widget_title = get_option('my_post_meta_widget_title');
        }
        $widget_title = ($widget_title) ? $widget_title : 'About This Post';
        ?&gt;
        &lt;p&gt;
            &lt;input name="my_post_meta_widget_use_post_title" type="hidden" value="0" /&gt;
            &lt;input id="my_post_meta_widget_use_post_title" name="my_post_meta_widget_use_post_title" type="checkbox" value="1" &lt;?php if($use_post_title) echo 'checked="checked" '; ?&gt;/&gt;
            &lt;label for="my_post_meta_widget_use_post_title"&gt;Use Post Title as Widget Title&lt;/label&gt;
        &lt;/p&gt;
        &lt;p&gt;
            &lt;label for="my_post_meta_widget_title"&gt;Widget Title&lt;/label&gt;&lt;br /&gt;
            &lt;input id="my_post_meta_widget_title" name="my_post_meta_widget_title" type="text" value="&lt;?php echo $widget_title; ?&gt;" /&gt;
        &lt;/p&gt;
        &lt;?php
    }
    wp_register_widget_control('my_post_meta_widget_id', 'Post Meta Widget', 'my_post_meta_widget_control');
?&gt;</pre>
<p>They look nice together, don’t they? The only trouble is that our control function is doing an awful lot of work for nothing. Right now, the widget function we created is completely ignoring our new options. Let’s drop in a few lines of code that will read our option values from the database and act appropriately:</p>
<pre>&lt;?php
    function my_post_meta_widget($args) {
        if( ! is_singular() ) return;
        extract($args);
<span class="highlight">        echo $before_widget.$before_title;

        $use_post_title = (int) get_option('my_post_meta_widget_use_post_title');
        if($use_post_title) {
            the_title();
        } else {
            $widget_title = get_option('my_post_meta_widget_title');
            $widget_title = ($widget_title) ? $widget_title : 'About This Post';
            echo $widget_title;
        }

        echo $after_title;</span>
        ?&gt;
        &lt;ul&gt;
            &lt;li class="date"&gt;&lt;?php the_time('F jS, Y'); ?&gt;&lt;/li&gt;
            &lt;li class="author"&gt;By &lt;?php the_author(); ?&gt;&lt;/li&gt;
            &lt;li class="comments"&gt;&lt;?php comments_number(); ?&gt;&lt;/li&gt;
            &lt;li class="categories"&gt;Categories: &lt;?php the_category(', '); ?&gt;&lt;/li&gt;
            &lt;li class="tags"&gt;Tags: &lt;?php the_tags(' ', ', ', ' '); ?&gt;&lt;/li&gt;
        &lt;/ul&gt;
        &lt;?php
        echo $after_widget;
    }
    wp_register_sidebar_widget('my_post_meta_widget_id', 'Post Meta Widget', 'my_post_meta_widget');

    function my_post_meta_widget_control(){

        if (isset($_POST['my_post_meta_widget_use_post_title'])) {
            $use_post_title = (int) $_POST['my_post_meta_widget_use_post_title'];
            update_option('my_post_meta_widget_use_post_title', $use_post_title);
        } else {
            $use_post_title = (int) get_option('my_post_meta_widget_use_post_title');
        }
        if (isset($_POST['my_post_meta_widget_title'])) {
            $widget_title = esc_attr($_POST['my_post_meta_widget_title']);
            update_option('my_post_meta_widget_title', $widget_title);
        } else {
            $widget_title = get_option('my_post_meta_widget_title');
        }
        $widget_title = ($widget_title) ? $widget_title : 'About This Post';
        ?&gt;
        &lt;p&gt;
            &lt;input name="my_post_meta_widget_use_post_title" type="hidden" value="0" /&gt;
            &lt;input id="my_post_meta_widget_use_post_title" name="my_post_meta_widget_use_post_title" type="checkbox" value="1" &lt;?php if($use_post_title) echo 'checked="checked" '; ?&gt;/&gt;
            &lt;label for="my_post_meta_widget_use_post_title"&gt;Use Post Title as Widget Title&lt;/label&gt;
        &lt;/p&gt;
        &lt;p&gt;
            &lt;label for="my_post_meta_widget_title"&gt;Widget Title&lt;/label&gt;&lt;br /&gt;
            &lt;input id="my_post_meta_widget_title" name="my_post_meta_widget_title" type="text" value="&lt;?php echo $widget_title; ?&gt;" /&gt;
        &lt;/p&gt;
        &lt;?php
    }
    wp_register_widget_control('my_post_meta_widget_id', 'Post Meta Widget', 'my_post_meta_widget_control');
?&gt;</pre>
<p>Alright, all set. Drop that into your functions.php and let the magic begin!</p>
]]></content:encoded>
			<wfw:commentRss>http://webpresencepartners.com/2011/12/22/creating-a-wordpress-post-meta-widget-part-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Creating a WordPress Post Meta Widget, Part 1</title>
		<link>http://webpresencepartners.com/2011/12/14/creating-a-wordpress-post-meta-widget-part-1/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=creating-a-wordpress-post-meta-widget-part-1</link>
		<comments>http://webpresencepartners.com/2011/12/14/creating-a-wordpress-post-meta-widget-part-1/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 20:01:12 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[For Developers]]></category>
		<category><![CDATA[WordPress Development]]></category>

		<guid isPermaLink="false">http://webpresencepartners.com/?p=732</guid>
		<description><![CDATA[This part one of a two part series on creating WordPress widgets. Part one will cover the widget itself, and part two will cover creating the widget’s settings panel that appears in the WordPress admin. About the Widget We’re Creating For our website, I wanted to display the post meta information (such as the author, [...]]]></description>
			<content:encoded><![CDATA[<p>This part one of a two part series on creating WordPress widgets. Part one will cover the widget itself, and part two will cover creating the widget’s settings panel that appears in the WordPress admin.</p>
<h2>About the Widget We’re Creating</h2>
<p>For our website, I wanted to display the post meta information (such as the author, date, categories, etc.) in the sidebar rather than above the article. I also wanted to be able to easily move it around if need be using the widgets panel in WordPress.</p>
<p>So, I decided to create a custom WordPress widget that displays information about the current post, but only if we’re on a single post. That means the widget does nothing and shows nothing if used on a blog archive or index page.</p>
<p>The widget will end up generating code that looks something like this:</p>
<pre>
&lt;div class=&quot;sidebar_widget&quot;&gt;
    &lt;h3&gt;About This Post&lt;/h3&gt;
    &lt;ul&gt;
        &lt;li&gt;December 13, 2011&lt;/li&gt;
        &lt;li&gt;by Daniel&lt;/li&gt;
        &lt;li&gt;No Comments&lt;/li&gt;
        &lt;li&gt;Categories: foo, bar&lt;/li&gt;
        &lt;li&gt;Tags: blee&lt;/li&gt;
    &lt;/ul&gt;
&lt;/div&gt;
</pre>
<p>Note that the div and h3 tags will be replaced with a few variables that allow WordPress to tell us what elements to wrap around our widget and its title.</p>
<h2>WordPress Functions We’ll Be Using</h2>
<p>Here’s a quick list of the WordPress functions we’ll be using below. Each item links to its page in the WordPress codex.</p>
<ul>
<li><a href="http://codex.wordpress.org/Function_Reference/is_singular">is_singular</a></li>
<li><a href="http://codex.wordpress.org/Function_Reference/get_option">get_option</a></li>
<li><a href="http://codex.wordpress.org/Function_Reference/the_title">the_title</a></li>
<li><a href="http://codex.wordpress.org/Function_Reference/the_time">the_time</a></li>
<li><a href="http://codex.wordpress.org/Function_Reference/the_author">the_author</a></li>
<li><a href="http://codex.wordpress.org/Function_Reference/comments_number">comments_number</a></li>
<li><a href="http://codex.wordpress.org/Function_Reference/the_category">the_category</a></li>
<li><a href="http://codex.wordpress.org/Function_Reference/the_tags">the_tags</a></li>
<li><a href="http://codex.wordpress.org/Function_Reference/wp_register_sidebar_widget">wp_register_sidebar_widget</a></li>
</ul>
<p><em>Note that we’re using wp_register_sidebar_widget and NOT register_sidebar_widget. register_sidebar_widget has been deprecated since version 2.8.</em></p>
<h2>How it Works</h2>
<p>Widgets are surprisingly simple to create in WordPress. There are really only two steps involved:<br />
Create a function that echos out the code you want displayed in your widget, making sure to include the before_widget, before_title, after_title, and after_widget code that WordPress supplies you with.<br />
Register your function with WordPress using the wp_register_sidebar_widget function.</p>
<h2>The Code</h2>
<p>The code inside the function is pretty much up to you to write however you see fit. However, there are a few things you need to have. First, your function must accept a single argument, which is an associative array with the following keys:</p>
<ul>
<li>before_widget</li>
<li>before_title</li>
<li>after_title</li>
<li>after_widget</li>
</ul>
<p>If you take a look at the example HTML earlier in this post (along with the note below it) and the array keys above, things should start to make some sense.</p>
<p>To make it easier to use the items from the array, we’re going to use PHP’s extract function to create variables from our array and its keys. Now we have access to these handy variables:</p>
<ul>
<li>$before_widget</li>
<li>$before_title</li>
<li>$after_title</li>
<li>$after_widget</li>
</ul>
<p>So far, our code looks something like this:</p>
<pre>
&lt;?php
function my_post_meta_widget($args) {
    extract($args);
}
?&gt;
</pre>
<p>Now let’s make our widget function actually do something by echoing some code out to the browser. There are a few ways to accomplish this but because of the way the WordPress the_title, the_author, etc. functions work, I’m going to use a closing PHP tag output to the browser. Let’s see what that looks like:</p>
<pre>
&lt;?php
function my_post_meta_widget($args) {
    extract($args);
<span class="highlight">    ?&gt;
    &lt;ul&gt;
        &lt;li class=&quot;date&quot;&gt;&lt;?php the_time('F jS, Y'); ?&gt;&lt;/li&gt;
        &lt;li class=&quot;author&quot;&gt;By &lt;?php the_author(); ?&gt;&lt;/li&gt;
        &lt;li class=&quot;comments&quot;&gt;&lt;?php comments_number(); ?&gt;&lt;/li&gt;
        &lt;li class=&quot;categories&quot;&gt;Categories: &lt;?php the_category(', '); ?&gt;&lt;/li&gt;
        &lt;li class=&quot;tags&quot;&gt;Tags: &lt;?php the_tags(' ', ', ', ' '); ?&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;?php</span>
}
?&gt;
</pre>
<p>Now we have a nice function that displays some info about our post, but it’s not a real widget quite yet. We still need to wrap our markup in those fancy tags that WordPress gave us. Let’s do that.</p>
<pre>
&lt;?php
function my_post_meta_widget($args) {
    extract($args);
    <span class="highlight">echo $before_widget . $before_title . &#x2018;About This Post&#x2019; . $after_title;</span>
    ?&gt;
    &lt;ul&gt;
        &lt;li class=&quot;date&quot;&gt;&lt;?php the_time('F jS, Y'); ?&gt;&lt;/li&gt;
        &lt;li class=&quot;author&quot;&gt;By &lt;?php the_author(); ?&gt;&lt;/li&gt;
        &lt;li class=&quot;comments&quot;&gt;&lt;?php comments_number(); ?&gt;&lt;/li&gt;
        &lt;li class=&quot;categories&quot;&gt;Categories: &lt;?php the_category(', '); ?&gt;&lt;/li&gt;
        &lt;li class=&quot;tags&quot;&gt;Tags: &lt;?php the_tags(' ', ', ', ' '); ?&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;?php
    <span class="highlight">echo $after_widget;</span>
}
?&gt;
</pre>
<p>Let’s register it with WordPress and drop it in a sidebar to test it out. To let WordPress know that the sidebar exists, we have to use the function wp_register_sidebar_widget, which looks something like this:</p>
<pre>
&lt;?php wp_register_sidebar_widget($id, $name, $callback); ?&gt;
</pre>
<p>There are a few other arguments you can include, but we’re not worried about those right now. For now, let’s register our widget right after our function definition. For the id argument, we just need a unique string that will identify our widget. I’m going to use my_post_meta_widget_id. The complete code should now look like this:</p>
<pre>
&lt;?php
function my_post_meta_widget($args) {
    extract($args);
    echo $before_widget . $before_title . &#x2018;About This Post&#x2019; . $after_title;
    ?&gt;
    &lt;ul&gt;
        &lt;li class=&quot;date&quot;&gt;&lt;?php the_time('F jS, Y'); ?&gt;&lt;/li&gt;
        &lt;li class=&quot;author&quot;&gt;By &lt;?php the_author(); ?&gt;&lt;/li&gt;
        &lt;li class=&quot;comments&quot;&gt;&lt;?php comments_number(); ?&gt;&lt;/li&gt;
        &lt;li class=&quot;categories&quot;&gt;Categories: &lt;?php the_category(', '); ?&gt;&lt;/li&gt;
        &lt;li class=&quot;tags&quot;&gt;Tags: &lt;?php the_tags(' ', ', ', ' '); ?&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;?php
    echo $after_widget;
}
<span class="highlight">wp_register_sidebar_widget(&#x2018;my_post_meta_widget_id&#x2019;, &#x2018;Post Meta Widget&#x2019;, &#x2018;my_post_meta_widget&#x2019;);</span>
?&gt;
</pre>
<p>We’re in the home stretch! Since our widget is displaying information about a single post, we only want it to appear when we’re displaying a single item, not archives, indexes, or search results pages.</p>
<p>Achieving this behavior is actually quite simple. We just need to add the WordPress conditional tag is_singular to our code to determine whether or not were looking at a singular item. In this case, if we’re not looking at a singular item, we do nothing.</p>
<pre>
&lt;?php
function my_post_meta_widget($args) {
    <span class="highlight">if( ! is_singular() ) return;</span>
    extract($args);
    echo $before_widget . $before_title . &#x2018;About This Post&#x2019; . $after_title;
    ?&gt;
    &lt;ul&gt;
        &lt;li class=&quot;date&quot;&gt;&lt;?php the_time('F jS, Y'); ?&gt;&lt;/li&gt;
        &lt;li class=&quot;author&quot;&gt;By &lt;?php the_author(); ?&gt;&lt;/li&gt;
        &lt;li class=&quot;comments&quot;&gt;&lt;?php comments_number(); ?&gt;&lt;/li&gt;
        &lt;li class=&quot;categories&quot;&gt;Categories: &lt;?php the_category(', '); ?&gt;&lt;/li&gt;
        &lt;li class=&quot;tags&quot;&gt;Tags: &lt;?php the_tags(' ', ', ', ' '); ?&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;?php
    echo $after_widget;
}
wp_register_sidebar_widget(&#x2018;my_post_meta_widget_id&#x2019;, &#x2018;Post Meta Widget&#x2019;, &#x2018;my_post_meta_widget&#x2019;);
?&gt;
</pre>
<p>That’s all there is to it. Drop the code above into your functions.php and use the widgets panel in WordPress to place your fancy new widget on your blog sidebar.</p>
<p>In the next post, I’ll show you how to add options to your widget so you can customize the title or just about anything else you need!</p>
]]></content:encoded>
			<wfw:commentRss>http://webpresencepartners.com/2011/12/14/creating-a-wordpress-post-meta-widget-part-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hey Look, a Blog!</title>
		<link>http://webpresencepartners.com/2011/12/13/hey-look-a-blog/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hey-look-a-blog</link>
		<comments>http://webpresencepartners.com/2011/12/13/hey-look-a-blog/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 23:01:49 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://webpresencepartners.com/?p=745</guid>
		<description><![CDATA[We just recently updated our website and are very happy to be adding a blog as well! Check this space for WordPress tips, business and marketing info, and anything else we can find that&#8217;s nerdy or business related. If you have suggestions of your own, please let us know in the comments or by contacting [...]]]></description>
			<content:encoded><![CDATA[<p>We just recently updated our website and are very happy to be adding a blog as well! Check this space for WordPress tips, business and marketing info, and anything else we can find that&#8217;s nerdy or business related.</p>
<p>If you have suggestions of your own, please let us know in the comments or by <a href="http://webpresencepartners.com/get-in-touch/">contacting us</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://webpresencepartners.com/2011/12/13/hey-look-a-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

