<?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>Digging into WordPress &#187; tricks</title>
	<atom:link href="http://digwp.com/tag/tricks/feed/" rel="self" type="application/rss+xml" />
	<link>http://digwp.com</link>
	<description>Take your WordPress skills to the next level.</description>
	<lastBuildDate>Thu, 09 Feb 2012 19:03:45 +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>Smarter Slugs ~!@$%^&amp;*()={}[]?</title>
		<link>http://digwp.com/2012/01/smarter-slugs/</link>
		<comments>http://digwp.com/2012/01/smarter-slugs/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 19:39:26 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[permalink]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=5620</guid>
		<description><![CDATA[See those crazy characters in the title of this post? Now see how they don&#8217;t appear in the post&#8217;s URL? That&#8217;s one of the finer details of the WordPress 3.3 update: smarter permalink slugs. So when you type something like you see in the title of this post, with all the funky characters, or even [...]]]></description>
			<content:encoded><![CDATA[<p>See those crazy characters in the title of this post? Now see how they <em>don&#8217;t</em> appear in the post&#8217;s URL? That&#8217;s one of the <em>finer details</em> of the WordPress 3.3 update: <strong>smarter permalink slugs</strong>.</p>
<p><span id="more-5620"></span></p>
<p>So when you type something like you see in the title of this post, with all the funky characters, or even just something like a comma, apostrophe, or semi-colon, WordPress 3.3+ works the magic and automatically creates your post slug without the junk. </p>
<h3>Details.</h3>
<p>It may not seem like a big deal, but previous versions of WordPress would include those funky characters when auto-creating your permalink slugs. If you glance at URLs while surfing around WordPress-powered sites, keep an eye on the URL in the address bar. It&#8217;s common to see all sorts of non-alphanumeric stuff in there.</p>
<p>Does it matter? I think so, for numerous reasons:</p>
<ul>
<li><strong>Readability, consistency</strong> &ndash; simple alphanumeric URLs work great everywhere, no need to clutter them up with redundant information. For example, funky characters can choke URL-shortening services. Also: fewer characters, facilitates better comprehension.</li>
<li><strong>Safer</strong> &ndash; certain characters such as <code>`</code>, <code>^</code>, <code>"</code>, <code>~</code>, <code>#</code>, <code>%</code>, <code>|</code>, <code>\</code>, <code>&lt;</code>, <code>&gt;</code>, <code>"</code>, <code>~</code>, <code>[</code>, <code>]</code>, <code>{</code>, <code>}</code>, and the blank space are considered as unsafe and should not be included in the URI (ie., always need encoded). Including them may seem to work, but you&#8217;re introducing sort of unknown variable into the mix, a potential vulnerability<a href="#ref" title="Jump to reference link">*</a></li>
<li><strong>SEO</strong> &mdash; do funky characters like blank spaces and percentage signs in the URL <em>hurt</em> your site&#8217;s SEO? Maybe not, but why put anything in there that <em>isn&#8217;t</em> a keyword?</li>
</ul>
<p>So smarter auto-slugs in WordPress 3.3, another one of the <em>finer details</em> that improves the overall WP post-editing experience, and something you may not have noticed.</p>
<h3>Bonus tip</h3>
<p>Another sort of related &ldquo;smarter-slugs&rdquo; feature noticed while looking into it, is the automatic removal of the &ldquo;-2&rdquo; that WordPress automatically appends to the post slug when a duplicate is detected. So for example, say you&#8217;re working on a new post:</p>
<ol>
<li>Create a post with a slug such as &ldquo;<code>test-post</code>&rdquo;</li>
<li>Delete the post and send to the Trash</li>
<li>Create another post with the same &ldquo;<code>test-post</code>&rdquo; slug</li>
<li>WordPress detects the duplicate post in the database and appends a &ldquo;-2&rdquo;, like so: <code>test-post-2</code> to the post slug</li>
<li>Create yet another post with the same slug and WordPress will append a &ldquo;-3&rdquo;, and so on..</li>
</ol>
<p>Nobody likes the &ldquo;dash-twos&rdquo; but they are required for the auto-creation of non-duplicate post slugs. What I just noticed with version 3.3 is that, once you empty the Trash, <strong>WordPress automagically removes the &ldquo;-2&rdquo; from the post slug</strong>, improving workflow to save you time. This may have changed in a previous version and I just hadn&#8217;t noticed, or it&#8217;s another one of the <em>administrative refinements</em> of WordPress 3.3.</p>
<p><strong>Update:</strong> it looks like the -2 removal only applies to <strong>drafts</strong> and <strong>pending</strong> posts, not to posts that have already been published.. (see <a href="#comment-32497">comment from Otto</a>)</p>
<p id="ref"><strong>*</strong> More info on <a href="http://perishablepress.com/press/2009/03/08/building-the-perishable-press-4g-blacklist/" title="Building the Perishable Press 4G Blacklist">forbidden characters and blocking them</a></p>
<hr />
<p><small>© 2012 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2012/01/smarter-slugs/">Permalink</a> | <a href="http://digwp.com/2012/01/smarter-slugs/#comments">14 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2012/01/smarter-slugs/&title=Smarter Slugs ~!@$%^&#038;*()={}<>[]?">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/permalink/" rel="tag">permalink</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2012/01/smarter-slugs/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Goodbye Admin Bar, Hello Toolbar</title>
		<link>http://digwp.com/2012/01/goodbye-admin-bar-hello-toolbar/</link>
		<comments>http://digwp.com/2012/01/goodbye-admin-bar-hello-toolbar/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 21:24:40 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[admin-bar]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=5574</guid>
		<description><![CDATA[When the Admin Bar hit the streets in WordPress 3.1, people seemed to either love it or hate it. And rightly so, it was a significant change in the appearance of the WP Admin area, and if not disabled in your User Profile, the front-end of your site as well. Many tips, tricks and plugins [...]]]></description>
			<content:encoded><![CDATA[<p>When the Admin Bar hit the streets in WordPress 3.1, people seemed to <a title="Poll: Love or Hate the WordPress Admin Bar" href="http://digwp.com/2011/04/poll-love-hate-admin-bar/">either love it or hate it</a>. And rightly so, it was a significant change in the appearance of the WP Admin area, and if not disabled in your <em>User Profile</em>, the front-end of your site as well. Many <a title="Admin Bar Tricks" href="http://digwp.com/2011/04/admin-bar-tricks/">tips, tricks and plugins for customizing the Admin Bar</a> began appearing around the Web. And then just as the dust began to settle, BAM — the &#8220;Admin Bar&#8221; transforms into the &#8220;Toolbar&#8221; with the <a href="http://wordpress.org/news/2011/12/sonny/">WordPress 3.3 update</a>.</p>
<p><span id="more-5574"></span></p>
<p>The WordPress 3.3 update focused heavily on streamlining and optimizing the Admin experience. The Admin Bar of WP 3.1 was intended as the &#8220;first step toward a front-end editor&#8221;. The original Admin Bar was debated for several good reasons:</p>
<ul>
<li>It&#8217;s enabled on the front-end by default</li>
<li>Gobbles up too much vertical screen space</li>
<li>It&#8217;s redundant, all links available elsewhere</li>
<li>It&#8217;s not visually appealing in general</li>
</ul>
<p>Using the <a title="Admin Bar Tricks" href="http://digwp.com/2011/04/admin-bar-tricks/">many Admin Bar tricks</a> that became available around the Web, WordPress users dealt with the thing in their own way and moved on with their lives. Some use plugins, some custom snippets &amp; scripts, some just love it as-is. But now with the new 3.3 update, the <strong>big question</strong> is &#8220;what works and what doesn&#8217;t?&#8221; We&#8217;re glad you asked..</p>
<h3>Admin Bar is dead, long live the Toolbar</h3>
<p>If you&#8217;ve updated to <a href="http://codex.wordpress.org/Version_3.3">WP 3.3</a>, you&#8217;ve seen the smaller &#8220;Toolbar&#8221; tucked neat above the Admin area. The new <span style="text-decoration: line-through;">Admin Bar</span> Toolbar seems to address <em>some</em> of the main concerns about the old Admin Bar:</p>
<ul>
<li>No longer enabled on front-end by default</li>
<li>Uses less vertical screen space</li>
<li>Integrates the Admin header area, so no longer redundant</li>
<li>It looks a little better (in my opinion)</li>
</ul>
<p>For those who have not yet updated or have no idea what&#8217;s going on, here is a visual comparison of the old &#8220;Admin Bar&#8221; and the new &#8220;Toolbar&#8221;:</p>
<p><img src="http://digwp.com/wp-content/blog-images/wp-admin-bar-01.jpg" alt="[ The 'old' WP Admin Bar ]" /><br />
<small><em>Admin Bar: bigger, clunkier, and redundant</em></small></p>
<p><img src="http://digwp.com/wp-content/blog-images/wordpress-toolbar-01.jpg" alt="[ The 'new' WP Toolbar ]" /><br />
<small><em>Toolbar: smaller, simpler, and required</em></small></p>
<p>The new Toolbar certainly looks better, but <a title="WP Forum &gt; Hiding admin bar in WordPress 3.3" href="http://wordpress.org/support/topic/hiding-admin-bar-in-wordpress-33">concerns remain</a>. From what I&#8217;ve gathered, the main gripe is that the Toolbar is <em>mandatory</em>, and possibly still redundant, depending on site setup and configuration (plugins, networks, etc.). Is it really <em>mandatory</em>? That sounds silly to me, but seems to be the case:</p>
<p><img src="http://digwp.com/wp-content/blog-images/wp-admin-bar.jpg" alt="[ The 'old' WP Admin Bar ]" /><br />
<small><em>User Profile settings for the old Admin Bar: full control</em></small></p>
<p><img src="http://digwp.com/wp-content/blog-images/wordpress-toolbar.jpg" alt="[ The 'new' WP Toolbar ]" /><br />
<small><em>User Profile settings for the Toolbar: bamboozled! No option to disable for back-end</em></small></p>
<p>So yeah, <em>something changed</em>, so the question for the Admin Toolbar is “<strong>what works and what doesn&#8217;t?</strong>” Let&#8217;s dig in and see what&#8217;s up..</p>
<h3>Admin Bar changes, now WP Toolbar</h3>
<p>As <a href="http://wordpress.org/support/topic/hiding-admin-bar-in-wordpress-33#post-2495448">Ipstenu puts it</a>: &#8220;You don&#8217;t have to like it, but it&#8217;s here to stay.&#8221; So it&#8217;s time to look at things practically and get on with it. First of all, if you have a plugin or functions script that hides, removes, or customizes the Admin Bar, definitely investigate to see if everything is still working according to plan.</p>
<h4>What works..</h4>
<p>After some testing, we&#8217;ve seen the following <code>functions.php</code> snippets continue to work in WordPress version 3.3:</p>
<pre><code>// disable the admin bar (front end only) show_admin_bar(false); // disable the admin bar (front end only) add_filter('show_admin_bar', '__return_false');</code></pre>
<p>In WP 3.1, these functions hid the Admin Bar on <em>both sides</em> of the fence — front end &amp; back end. In WP 3.3+, these snippets will hide the Admin Toolbar <strong>only on the front-end</strong> of your site (the public side). Likewise, this snippet of CSS added to your theme&#8217;s <code>style.css</code> file <em>hides</em> the Toolbar on the <em>front-end</em>:</p>
<pre><code>/* hide the admin bar (front end only) */ #wpadminbar { display:none; }</code></pre>
<p>Keep in mind that, when using the CSS method, the Toolbar markup is still present in the source code, but will not be displayed in the browser.</p>
<p>Here is another useful snippet for disabling the Toolbar for lesser users:</p>
<pre><code>// show admin bar only for admins if (!current_user_can('manage_options')) { add_filter('show_admin_bar', '__return_false'); } // show admin bar only for admins and editors if (!current_user_can('edit_posts')) { add_filter('show_admin_bar', '__return_false'); }</code></pre>
<p>Note that this also only applies to Toolbar display on the front-end.</p>
<h4>What doesn&#8217;t work..</h4>
<p>Basically the <code>show_admin_bar()</code> function seems to work as it did before version 3.3, except that now the Toolbar is integral to the Admin area, so disabling it using the previous functions works only on the front-end of your site. So tricks like this stopped working:</p>
<pre></pre>
<p>If you&#8217;re running WP 3.1+ or 3.2+ (not 3.3+), then <code>show_admin_bar()</code> will continue to disable the Admin Bar on both front and back ends of WordPress.</p>
<h3>Admin Bar plugins</h3>
<p>In our <a href="http://digwp.com/">book</a>, we provide a list of plugins to help with customizing the 3.1 Admin Bar. Now working on the <a href="http://digwp.com/2011/12/poll-results-book-news-and-more/">DiW 3.3 update</a>, it&#8217;s time to check these plugins for compatibility with <strong>WordPress 3.3</strong>. Here are the results:</p>
<ul>
<li><a href="http://wordpress.org/extend/plugins/admin-bar/">Admin Bar Remover</a> — disables Toolbar on front-end only</li>
<li><a href="http://wordpress.org/extend/plugins/wp-admin-bar-removal/">Admin Bar Removal</a> — doesn&#8217;t work in WP 3.3+</li>
<li><a href="http://wordpress.org/extend/plugins/admin-bar-disabler/">Admin Bar Disabler</a> — disables Toolbar on front-end only</li>
<li><a href="http://wordpress.org/extend/plugins/admin-bar-minimiser/">Admin Bar Minimiser</a> — hides/minimizes Toolbar on both sides of WP 3.3, but looks weird because of the existing Admin design. Also, in the Admin the hover/toggle button is <a href="http://digwp.com/wp-content/blog-images/wordpress-toolbar-02.jpg">invisible</a>.</li>
<li><a href="http://wordpress.org/extend/plugins/global-admin-bar-hide-or-remove/">Global Hide/Remove Admin Bar Plugin</a> — removes the User Profile Toolbar settings and removes Toolbar on front-end only</li>
<li><a href="http://wordpress.org/extend/plugins/hide-admin-bar-search/">Hide Admin Bar Search</a> — there is no search bar in WP 3.3</li>
<li><a href="http://wordpress.org/extend/plugins/stick-admin-bar-to-bottom/">Stick Admin Bar To Bottom</a> — works great on both sides of WP 3.3</li>
<li><a href="http://wordpress.org/extend/plugins/wp-custom-admin-bar/">WP Custom Admin Bar</a> — didn&#8217;t seem to work..</li>
<li><a href="http://blog.ftwr.co.uk/archives/2011/01/05/always-show-admin-bar/">Always show admin bar</a> — works in 3.3 but applies only to front-end</li>
<li><strong>Update:</strong> <a href="http://wordpress.org/extend/plugins/ultimate-admin-bar/">Ultimate Admin Bar</a> — puts it <em>all</em> in the Toolbar to further optimize your workflow</li>
</ul>
<p>If you know of others, shout em out and I&#8217;ll update the post.</p>
<h3>To be continued..</h3>
<p>Without a doubt things will continue to change, and it&#8217;ll be fun watching as WordPress continues to evolve, Toolbar and all :)</p>
<hr />
<p><small>© 2012 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2012/01/goodbye-admin-bar-hello-toolbar/">Permalink</a> | <a href="http://digwp.com/2012/01/goodbye-admin-bar-hello-toolbar/#comments">16 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2012/01/goodbye-admin-bar-hello-toolbar/&title=Goodbye Admin Bar, Hello Toolbar">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/admin/" rel="tag">Admin</a>, <a href="http://digwp.com/tag/admin-bar/" rel="tag">admin-bar</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2012/01/goodbye-admin-bar-hello-toolbar/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Displaying Theme Data with WordPress</title>
		<link>http://digwp.com/2011/12/displaying-theme-data-with-wordpress/</link>
		<comments>http://digwp.com/2011/12/displaying-theme-data-with-wordpress/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 18:36:29 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=5457</guid>
		<description><![CDATA[A cool trick you can do with WordPress is display information directly from your theme&#8217;s style.css stylesheet. I recently used this on a site where the theme&#8217;s version number is used throughout the template to keep things current and consistent. get_theme_data() The function that makes it possible is called get_theme_data(), and it simply returns an [...]]]></description>
			<content:encoded><![CDATA[<p>A cool trick you can do with WordPress is display information directly from your theme&#8217;s <code>style.css</code> stylesheet. I recently used this on a site where the theme&#8217;s version number is used throughout the template to keep things current and consistent.</p>
<p><span id="more-5457"></span></p>
<h3>get_theme_data()</h3>
<p>The function that makes it possible is called <a href="http://codex.wordpress.org/Function_Reference/get_theme_data">get_theme_data()</a>, and it simply returns an array of information about any of your theme files. Here is how it&#8217;s used in your theme template:</p>
<pre><code>&lt;?php get_theme_data( $theme_filename ); ?&gt;</code></pre>
<p>So <code>$theme_filename</code> is required and should be the path and filename of your theme&#8217;s <code>style.css</code> file. There is no default value for this, so you need to ensure a proper value.</p>
<p>So what information can you display with <code>get_theme_data()</code>? The function returns an array of values that basically comprises the different meta items in your stylesheet. Here is a list of possible return values (all strings):</p>
<ul>
<li><code>Name</code> &ndash; theme name</li>
<li><code>Title</code> &ndash; either theme name or linked theme name</li>
<li><code>URI</code> &ndash; theme <abbr title="Uniform Resource Identifier">URI</abbr></li>
<li><code>Description</code> &ndash; wptexturized version of the theme name</li>
<li><code>AuthorURI</code> &ndash; theme author URI</li>
<li><code>Template</code> &ndash; theme parent template, if exists</li>
<li><code>Version</code> &ndash; theme version number</li>
<li><code>Status</code> &ndash; theme status (default: <code>publish</code>)</li>
<li><code>Tags</code> &ndash; theme tags</li>
<li><code>Author</code> &ndash; author name or linked author name</li>
</ul>
<p>Note that these return values are <strong>case-sensitive</strong> and will not work if the first letter is not capitalized.</p>
<h3>Examples</h3>
<p>The Codex provides this example for getting and displaying the theme <code>Name</code> and <code>Author</code>:</p>
<pre><code>&lt;?php

    /*
     * Assign theme folder name that you want to get information.
     * make sure theme exist in wp-content/themes/ folder.
     */

    $theme_name = 'twentyeleven'; 

   /*
    * Do not use get_stylesheet_uri() as $theme_filename,
    * it will result in PHP fopen error if allow_url_fopen is set to Off in php.ini,
    * which is what most shared hosting does. You can use get_stylesheet_directory()
    * or get_template_directory() though, because they return local paths.
    */

    $theme_data = get_theme_data( get_theme_root() . '/' . $theme_name . '/style.css' );
    echo $theme_data['Title'];
    echo $theme_data['Author'];

?&gt;</code></pre>
<p>This should get you going.. just copy/paste into your theme template and indicate the theme name in that first line of code. Displaying other bits of theme data is matter of editing/replicating those last two lines. </p>
<p>Once you see how it works, you can do cool stuff with it, like display your theme&#8217;s version number sort of globally throughout your site. I&#8217;m using this technique to append version parameters to my stylesheet <abbr title="Uniform Resource Locator">URL</abbr>s, like so:</p>
<pre><code>&lt;link rel="stylesheet" href="&lt;?php bloginfo('stylesheet_directory'); ?&gt;/style.css&lt;?php if(function_exists('theme_version')) theme_version(); ?&gt;"&gt;</code></pre>
<p>..and the output markup looks like this (notice the appended version parameter, <code>?v=1.3</code>):</p>
<pre><code>&lt;link rel="stylesheet" href="http://example.com/wp-content/themes/xycss/style.css?v=1.3"&gt;</code></pre>
<p>Because I am using multiple stylesheets, this method really saves a LOT of time trying to keep track of everything. Here is the <code>theme_version()</code> function that goes in your theme&#8217;s <code>functions.php</code> file:</p>
<pre><code>// display version number
function theme_version() {
    $theme_name = 'xycss'; // customize with your theme name
    $theme_data = get_theme_data( get_theme_root() . '/' . $theme_name . '/style.css' );
    echo '?v=' . $theme_data['Version'];
}</code></pre>
<p>And with a few modifications, you can also display your theme&#8217;s information in your posts and pages via <strong>shortcode</strong>:</p>
<pre><code>// version number shortcode
function theme_version_shortcode() {
    $theme_name = 'xycss'; // customize with your theme name
    $theme_data = get_theme_data( get_theme_root() . '/' . $theme_name . '/style.css' );
    return $theme_data['Version'];
}
add_shortcode('theme_version', 'theme_version_shortcode');</code></pre>
<p>With that second snippet in your <code>functions.php</code> file, displaying your theme info directly in pages is as easy as writing this:</p>
<p><code>[theme_version]</code></p>
<p>..and the output:</p>
<p><code>1.3</code></p>
<p>It&#8217;s pretty cool stuff, and I&#8217;m sure there&#8217;s tons more you can do with it too. If you know any tricks or tips, please share in the comments, Thanks :)</p>
<hr />
<p><small>© 2011 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2011/12/displaying-theme-data-with-wordpress/">Permalink</a> | <a href="http://digwp.com/2011/12/displaying-theme-data-with-wordpress/#comments">10 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2011/12/displaying-theme-data-with-wordpress/&title=Displaying Theme Data with WordPress">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/theme/" rel="tag">Theme</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2011/12/displaying-theme-data-with-wordpress/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>That&#8217;s Not Spam: False Positives and Ham</title>
		<link>http://digwp.com/2011/10/ham-hunter/</link>
		<comments>http://digwp.com/2011/10/ham-hunter/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 17:14:23 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[spam]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=5349</guid>
		<description><![CDATA[Everyone loves a good comment. Readers benefit from the shared information and authors appreciate the conversation and feedback. But you gotta keep the spam out. Akismet and other anti-spam plugins do an excellent job of automating the process, but it&#8217;s a good idea to watch out for false positives: legitimate comments marked as spam. Rescuing [...]]]></description>
			<content:encoded><![CDATA[<p>Everyone loves a good comment. Readers benefit from the shared information and authors appreciate the conversation and feedback. But <strong>you gotta keep the spam out</strong>. Akismet and other anti-spam plugins do an excellent job of automating the process, but it&#8217;s a good idea to <strong>watch out for false positives</strong>: legitimate comments marked as spam. Rescuing ham comments from the spam pile <em>promotes healthy comment threads</em> and improves the <em>quality and reputation</em> of your site. In this <abbr title="Digging into WordPress">DiW</abbr> post, we explain how WordPress &amp; Akismet deal with spam, discuss anti-spam strategy, and share some ham-saving tips and tricks.</p>
<p><span id="more-5349"></span></p>
<h3>Know thy comments</h3>
<p>In WordPress, there are three types of responses: comments, pingbacks, and trackbacks. The <strong>status</strong> of any given response is either:</p>
<ul>
<li><strong>approved</strong> &ndash; appearing on your site</li>
<li><strong>spammed</strong> &ndash; flagged as spam</li>
<li><strong>moderated</strong> &ndash; on hold for review</li>
<li><strong>in the trash</strong> &ndash; marked for deletion</li>
</ul>
<p>Theoretically, you&#8217;re going to know about <em>approved</em> comments that appear on your site. Likewise, you&#8217;ll have a chance to review any <em>moderated</em> comments, and nothing makes it to the <em>trash</em> by accident, so you know about those as well. What you don&#8217;t always know about are <em>spam</em> comments flagged as such by a plugin. Some of these are going to be ham, and they can be tricky to spot, especially as the number of spam comments begins to climb.</p>
<h3>Out of the box</h3>
<p>Out of the box, WordPress doesn&#8217;t flag any response as spam, <em>unless</em> you add some phrases to the built-in <a href="http://digwp.com/2010/02/stop-spammers-custom-blacklist/" title="Stop Spammers and Other Scumbags with a Custom Blacklist">comment blacklist</a>. Then, any comments matching any phrases in your blacklist are sent to the spam pile. So the key to preventing <em>blacklist ham</em> (<em>mmmm</em>..) is being absolutely sure that you want <em>nothing to do</em> with any comments mentioning &#8220;baby uggs&#8221; or who knows what.</p>
<h3>Akismet &amp; ham stats</h3>
<p>It&#8217;s easy to <a href="http://digwp.com/2009/11/dont-need-plugins-to-stop-comment-spam/" title="You Don't Need Any Plugins to Stop Comment Spam">stop spam without plugins</a>, but activate Akismet and suddenly you&#8217;ve got greater accuracy, better automation, and some <strong>incredible-looking statistics</strong>. Here are Akismet stats for <strong>false positives</strong> during the last few months here at <a href="http://digwp.com/">DigWP.com</a>:</p>
<p><img src="http://digwp.com/wp-content/blog-images/ham-rescue-01.gif" alt="[ Akismet false positives ]" /></p>
<p>That&#8217;s good news, but don&#8217;t be fooled &ndash; the number of false positives also depends on you, the user. Seeing few false positives is good news if you&#8217;re actively looking for them, otherwise <em>who knows</em> how many ham comments have slipped through. We check for false positives fairly regularly, so the low numbers are great, as is the decreasing number of spam comments:</p>
<p><img src="http://digwp.com/wp-content/blog-images/ham-rescue-02.gif" alt="[ WP Spam Statistics ]" /></p>
<p>This is also a good sign, but it&#8217;s still smart to keep an eye on things and rescue as much ham as possible. Back in the day, I really got into analyzing teh spam &ndash; digging through the spam bin, looking for patterns, checking sources, and rescuing ham comments from the abyss. It&#8217;s fun if you have the time, but these days it&#8217;s better to just <em>get it done</em>..</p>
<h3>Ham-rescue tips</h3>
<p>Now that we&#8217;ve seen how it works, here are some clues for cleaving through large slabs of spam quickly and effectively..</p>
<ul>
<li><strong>Comment text</strong> &ndash; legit comments tend to <em>look</em> real and stand out among the junk</li>
<li><strong>Gravatars</strong> &ndash; usually a good signal of quality, but spammers can haz gravatars too</li>
<li><strong>Link text</strong> &ndash; stupid link text is a <em>huge</em> giveaway, like &#8220;Baby Ugg Boots&#8221; or whatever</li>
<li><strong>Site URL</strong> &ndash; anything more than a domain or first-level subdirectory is probably spam</li>
<li><strong>Excessive links</strong> &ndash; legitimate comments rarely contain more than one or two links</li>
</ul>
<p>Here&#8217;s a screenshot illustrating some of these aspects of spam. Of course, there are plenty more examples waiting for you in Ye Olde Spam Bin!</p>
<p><img class="tweak-post-image" src="http://digwp.com/wp-content/blog-images/ham-rescue-03.gif" alt="[ Random spam comments ]" /><br /><small>Gravatars really stand out, but aren&#8217;t always the ham you&#8217;re looking for</small></p>
<p>Those are the big giveaways, but it&#8217;s generally easier/quicker to scan for <em>ham</em> than spam. That is, rather than looking for evidence of spam, scan for signs of <em>legitimacy</em> and <em>quality</em>. So a good example would be scanning for gravatars &ndash; you&#8217;re not trying to find the grey mystery man icon, you&#8217;re looking for something original, like the flag icon in the previous screenshot. With some repetition, the visual clues sort of gel together and the ham just sort of jumps out at you as sift through the pile.</p>
<h3>Wrapping it up..</h3>
<p>So what did we learn? Spam is the bad stuff, ham is the good stuff. WordPress doesn&#8217;t flag anything as spam by itself unless you add phrases to the comment blacklist. Add a great anti-spam plugin such as Akismet to the mix, and you&#8217;ve made your life easier by automating the process. But if you care about your readers and their feedback, you should periodically scan through your spam comments and rescue any false positives. With some repetition, checking your spam and saving ham comments takes only a few minutes, improves the quality of your site, and keeps commentators happy and ready for more.</p>
<hr />
<p><small>© 2011 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2011/10/ham-hunter/">Permalink</a> | <a href="http://digwp.com/2011/10/ham-hunter/#comments">5 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2011/10/ham-hunter/&title=That&#8217;s Not Spam: False Positives and Ham">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/comments/" rel="tag">comments</a>, <a href="http://digwp.com/tag/spam/" rel="tag">spam</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2011/10/ham-hunter/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>3 Ways to Reset the WordPress Loop</title>
		<link>http://digwp.com/2011/09/3-ways-to-reset-the-wordpress-loop/</link>
		<comments>http://digwp.com/2011/09/3-ways-to-reset-the-wordpress-loop/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 16:28:23 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=5189</guid>
		<description><![CDATA[WordPress does an excellent job of keeping track of what&#8217;s happening with the loop, but once you start customizing parameters and setting up multiple loops, it&#8217;s a good idea to explicitly reset them using one of three WordPress template tags. In this DiW post, we&#8217;ll explore these techniques to get a better understanding of when [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress does an excellent job of keeping track of what&#8217;s happening with <a href="http://digwp.com/2011/05/loops/" title="4 Ways to Loop with WordPress">the loop</a>, but once you start customizing parameters and setting up <a href="http://perishablepress.com/press/tag/loops/" title="Posts about WordPress Loops">multiple loops</a>, it&#8217;s a good idea to explicitly <strong>reset</strong> them using one of <em>three WordPress template tags</em>. In this <abbr title="Digging into WordPress">DiW</abbr> post, we&#8217;ll explore these techniques to get a better understanding of when and how to use them in your WordPress themes.</p>
<p><span id="more-5189"></span></p>
<ul>
<li><a href="http://digwp.com/2011/09/3-ways-to-reset-the-wordpress-loop/#wp_reset_postdata">wp_reset_postdata()</a></li>
<li><a href="http://digwp.com/2011/09/3-ways-to-reset-the-wordpress-loop/#wp_reset_query">wp_reset_query()</a></li>
<li><a href="http://digwp.com/2011/09/3-ways-to-reset-the-wordpress-loop/#rewind_posts">rewind_posts()</a></li>
<li><em><a href="http://digwp.com/2011/09/3-ways-to-reset-the-wordpress-loop/#article-summary">Quick Summary</a></em></li>
</ul>
<h3 id="wp_reset_postdata">wp_reset_postdata()</h3>
<p>First up we have <a href="http://codex.wordpress.org/Function_Reference/wp_reset_postdata" title="Function Reference/wp reset postdata">wp_reset_postdata</a>, which restores the global <code>$post</code> variable to the current post in the main query. This is useful when using <code>WP_Query</code> to customize loops or create multiple loops on the same page. It looks like this:</p>
<p><code>&lt;?php wp_reset_postdata(); ?&gt;</code></p>
<p>This tag is nice and simple &ndash; it accepts no parameters and returns no values. It simply resets the post data after a custom query. So for example, let&#8217;s say we have a custom <code>WP_Query</code> loop in our theme&#8217;s <code>header.php</code> file, something like this:</p>
<pre><code>$random_post = new WP_query(); 
$random_post-&gt;query('cat=3&amp;showposts=1&amp;orderby=rand'); 
while ($random_post-&gt;have_posts()) : $random_post-&gt;the_post(); 
&lt;a href="&lt;?php the_permalink() ?&gt;" title="&lt;?php the_title(); ?&gt;"&gt;
	&lt;img src="&lt;?php echo get_post_meta($random_post-&gt;ID, 'featured', true); ?&gt;"&gt;
&lt;/a&gt;
endwhile;</code></pre>
<p>This would display a random post in the header, but it will also change the main query object for any other loops on the page. Without the original query data available, the main posts loop contained in, say, <code>index.php</code> may produce unexpected results. Fortunately, we can use <code>wp_reset_postdata</code> to restore the query object to its original state.</p>
<p>To use <code>wp_reset_postdata</code>, just place after your custom loop(s). Here is our previous example with <code>wp_reset_postdata</code> to reset the loop:</p>
<pre><code>$random_post = new WP_query(); 
$random_post-&gt;query('cat=3&amp;showposts=1&amp;orderby=rand'); 
while ($random_post-&gt;have_posts()) : $random_post-&gt;the_post(); 
&lt;a href="&lt;?php the_permalink() ?&gt;" title="&lt;?php the_title(); ?&gt;"&gt;
	&lt;img src="&lt;?php echo get_post_meta($random_post-&gt;ID, 'featured', true); ?&gt;"&gt;
&lt;/a&gt;
endwhile;
wp_reset_postdata();</code></pre>
<p class="highlight-text"><strong>When to use:</strong> best used after custom or multiple loops created with <code>WP_Query</code>.</p>
<h3 id="wp_reset_query">wp_reset_query()</h3>
<p>Next up we have the <a href="http://codex.wordpress.org/Function_Reference/wp_reset_query" title="Function Reference/wp reset query">wp_reset_query</a> function, which resets the query used with custom loops. It&#8217;s a simple function that accepts no parameters and returns no values. It looks like this:</p>
<p><code>&lt;?php wp_reset_query(); ?&gt;</code></p>
<p>Specifically, this function was <a href="http://core.trac.wordpress.org/ticket/4741" title="Multiple $wp_query objects mess a lot of things up">created to prevent issues with query_posts</a>, as indicated for the function in the <code>wp-includes/query.php</code> file:</p>
<pre><code>/**
 * Destroy the previous query and set up a new query.
 *
 * This should be used after {@link query_posts()} and before another {@link
 * query_posts()}. This will remove obscure bugs that occur when the previous
 * wp_query object is not destroyed properly before another is set up.
 *
 * @since 2.3.0
 * @uses $wp_query
 */</code></pre>
<p>Looking at the <code>wp_reset_query</code> function in <code>query.php</code>, we see that it uses the adjacent <a href="http://digwp.com/2011/09/3-ways-to-reset-the-wordpress-loop/#wp_reset_postdata">wp_reset_postdata</a> function to restore the global <code>$post</code> variable to the current post in the main query:</p>
<pre><code>// destroy and reset the query
function wp_reset_query() {
	unset($GLOBALS['wp_query']);
	$GLOBALS['wp_query'] =&amp; $GLOBALS['wp_the_query'];
	wp_reset_postdata(); // &lt;-- RESET QUERY
}

// restore the query
function wp_reset_postdata() {
	global $wp_query;
	if ( !empty($wp_query-&gt;post) ) {
		$GLOBALS['post'] = $wp_query-&gt;post;
		setup_postdata($wp_query-&gt;post);
	}
}</code></pre>
<p>So both <code>wp_reset_query()</code> and <code>wp_reset_postdata()</code> reset the query object by restoring the global <code>$post</code> variable, but <code>wp_reset_query</code> takes it a step further and actually <em>destroys</em> the previous query before doing so. This is important when using <code>query_posts()</code>, as seen in the following example:</p>
<pre><code>&lt;?php query_posts('posts_per_page=3');
if (have_posts()) : while (have_posts()) : the_post(); ?&gt;

&lt;h1&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h1&gt;

&lt;?php endwhile; endif; ?&gt;
&lt;?php wp_reset_query(); ?&gt;</code></pre>
<p class="highlight-text"><strong>When to use:</strong> best used after a <code>query_posts</code> loop to reset things after a custom query.</p>
<h3 id="rewind_posts">rewind_posts()</h3>
<p>Last but not least, we have the <a href="http://codex.wordpress.org/Function_Reference/rewind_posts" title="Function Reference/rewind posts">rewind_posts</a> function, which basically does what it says: rewinds the loop so you can re-use the same query. The function accepts no parameters, returns no values, and looks like this when used in your theme files:</p>
<p><code>&lt;?php rewind_posts(); ?&gt;</code></p>
<p>So to understand when to use <code>rewind_posts()</code>, let&#8217;s say we want to use the same query in two different locations on the page. We want to display post titles in the first loop and post content in the second loop. To re-use the same posts, we include <code>rewind_posts</code> after the first loop, like so:</p>
<pre><code>if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
&lt;h1&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h1&gt;
&lt;?php endwhile; endif; ?&gt;

&lt;?php rewind_posts(); ?&gt;

&lt;?php while (have_posts()) : the_post(); ?&gt;
&lt;?php the_content(); ?&gt;
&lt;?php endwhile; ?&gt;</code></pre>
<p>So, while <code>wp_reset_query</code> and <code>wp_reset_postdata</code> reset the entire query object, <code>rewind_posts</code> simply resets the post count, as seen for the function in the <code>wp-includes/query.php</code> file:</p>
<pre><code>// rewind the posts and reset post index
function rewind_posts() {
	$this-&gt;current_post = -1;
	if ( $this-&gt;post_count &gt; 0 ) {
		$this-&gt;post = $this-&gt;posts[0];
	}
}</code></pre>
<p class="highlight-text"><strong>When to use:</strong> best for re-using the same query on the same page.</p>
<h3 id="article-summary">5-second summary</h3>
<p>Quick summary for future reference:</p>
<ul>
<li><strong><code>wp_reset_postdata()</code></strong> -&gt; best used after custom or multiple loops created with <code>WP_Query</code></li>
<li><strong><code>wp_reset_query()</code></strong> -&gt; best used after a <code>query_posts</code> loop to reset a custom query</li>
<li><strong><code>rewind_posts()</code></strong> -&gt; best for re-using the same query on the same page</li>
</ul>
<p>I hope this is a useful round-up of when &amp; how to reset/rewind the WordPress loop. Note that the <a href="http://codex.wordpress.org/">WP Codex</a> information on these functions is kinda thin, so feel free to share any tips or examples in the comments.</p>
<hr />
<p><small>© 2011 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2011/09/3-ways-to-reset-the-wordpress-loop/">Permalink</a> | <a href="http://digwp.com/2011/09/3-ways-to-reset-the-wordpress-loop/#comments">11 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2011/09/3-ways-to-reset-the-wordpress-loop/&title=3 Ways to Reset the WordPress Loop">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/loop/" rel="tag">loop</a>, <a href="http://digwp.com/tag/php/" rel="tag">PHP</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2011/09/3-ways-to-reset-the-wordpress-loop/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Secure uploads, upgrade and other directories with .htaccess</title>
		<link>http://digwp.com/2011/06/secure-upload-upgrade-directories/</link>
		<comments>http://digwp.com/2011/06/secure-upload-upgrade-directories/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 00:20:53 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=4519</guid>
		<description><![CDATA[It sucks, but a lot of plugins require certain directories to be set at CHMOD 777 for its file permissions. Of course, you should not use any plugin that requires 777 directories, but if you absolutely must, you can help protect the folder by adding a thin slice of htaccess. This works great for any [...]]]></description>
			<content:encoded><![CDATA[<p>It sucks, but a lot of plugins require certain directories to be set at CHMOD 777 for its file permissions. Of course, you should not use any plugin that requires 777 directories, but if you absolutely must, you can help protect the folder by adding a thin slice of htaccess. This works great for any directory requiring &#8220;loose-ish&#8221; permissions (i.e., anything greater than 755), and may also be useful for other key folders as well.</p>
<p><span id="more-4519"></span></p>
<p>They key here is that only <em>you and the server</em> need access to the folder that you want to protect, so for example, stuff like:</p>
<ul>
<li>uploads</li>
<li>upgrade</li>
<li>backups</li>
<li>cache-123</li>
<li>temp-123</li>
<li>etc..</li>
</ul>
<p>Anything that regular users aren&#8217;t going to need to access. Then, you&#8217;ll also need the IP address of your server and your own machine. Once you have that information, use it to edit the following code:</p>
<pre><code>Order Deny,Allow
Deny from all
Allow from 123.456.789.0
Allow from 0.123.456.789</code></pre>
<p>You can emulate the &#8220;Allow from&#8221; lines to allow more IP addresses. Like maybe you&#8217;ve got a remote office or something. Once the code is ready, just copy and paste into an htaccess file located in the directory you would like to protect. Fix it and forget it, as they say..</p>
<p>I use this code on several sites and it works great. Only takes a minute to setup, and greatly improves the security of otherwise potentially vulnerable directories.</p>
<hr />
<p><small>© 2011 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2011/06/secure-upload-upgrade-directories/">Permalink</a> | <a href="http://digwp.com/2011/06/secure-upload-upgrade-directories/#comments">18 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2011/06/secure-upload-upgrade-directories/&title=Secure uploads, upgrade and other directories with .htaccess">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/htaccess-2/" rel="tag">htaccess</a>, <a href="http://digwp.com/tag/security/" rel="tag">Security</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2011/06/secure-upload-upgrade-directories/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Admin Bar Tricks</title>
		<link>http://digwp.com/2011/04/admin-bar-tricks/</link>
		<comments>http://digwp.com/2011/04/admin-bar-tricks/#comments</comments>
		<pubDate>Mon, 25 Apr 2011 16:20:23 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[admin-bar]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=4020</guid>
		<description><![CDATA[According to our latest poll, so far the votes are pretty much split on whether people love, hate, or don&#8217;t care about WordPress&#8217; new Admin Bar. Over time, it looks like &#8220;Hate it&#8221; has started to pull ahead, but it doesn&#8217;t matter because the Admin Bar is here to stay, regardless of opinion. Already there [...]]]></description>
			<content:encoded><![CDATA[<p>According to our <a href="http://digwp.com/2011/04/poll-love-hate-admin-bar/" title="Poll: Love or Hate the WordPress Admin Bar">latest poll</a>, so far the votes are pretty much split on whether people <em>love</em>, <em>hate</em>, or <em>don&#8217;t care</em> about WordPress&#8217; new Admin Bar. Over time, it looks like &#8220;Hate it&#8221; has started to pull ahead, but it doesn&#8217;t matter because <strong>the Admin Bar is here to stay</strong>, regardless of opinion. Already there are many awesome ways to make it do virtually <em>whatever you want</em>. In this <abbr title="Digging into WordPress">DigWP</abbr> post, we round up a ton of tips, tricks, and plugins for ultimately mastering the WordPress Admin Bar.</p>
<p><span id="more-4020"></span></p>
<p>Here is our menu of <strong>Admin Bar Tricks</strong> for WordPress 3.1 and better:</p>
<ul>
<li><a href="#disable-for-users">Disable the Admin Bar for individual users</a></li>
<li><a href="#disable-for-theme">Disable the Admin Bar for all users of the current theme</a></li>
<li><a href="#disable-for-non-admins">Disable the Admin Bar for non-Admins only</a></li>
<li><a href="#always-show">Always show the Admin Bar</a></li>
<li><a href="#move-to-bottom">Move the Admin Bar to the bottom</a></li>
<li><a href="#add-remove-links">Add or Remove links from the Admin Bar</a></li>
<li><a href="#clean-profile">Clean up User Profile Page</a></li>
<li><a href="#admin-bar-plugins">Disable and Customize the Admin Bar with Plugins</a></li>
<li><a href="#admin-bar-resources">Even More Admin Bar Resources</a></li>
</ul>
<h3 id="disable-for-users">Disable the Admin Bar for individual users</h3>
<p>By default, each registered user has the option of showing the Admin on the frontend and/or back-end of the site. Thus, to change your preferences, just visit <strong>Users</strong> &gt; <strong>Your Profile</strong> and choose your options as seen here:</p>
<p><img src="http://digwp.com/wp-content/blog-images/admin-bar-settings.gif" alt="[ Screenshot: Admin Bar Settings ]" /></p>
<p>Unfortunately, this gets kind of tedious when customizing profiles for many users. Fortunately, we&#8217;re just getting started, so read ahead to see more efficient ways of disabling and modifying the WordPress Admin Bar.</p>
<h3 id="disable-for-theme">Disable the Admin Bar for all users of the current theme</h3>
<p>To cleanly disable the Admin Bar for all users of your theme (and thus your site), add this snippet to your theme’s <code>functions.php</code> file:</p>
<pre><code>// disable the admin bar
show_admin_bar(false);</code></pre>
<p>Alternately, you may use this method, which filters the <code>show_admin_bar</code> function:</p>
<pre><code>// disable the admin bar
add_filter('show_admin_bar', '__return_false');</code></pre>
<p>Another option is to hide the Admin Bar using <abbr title="Cascading Style Sheets">CSS</abbr>. To do so, paste this into your<br />
theme’s <code>style.css</code> (or other stylesheet):</p>
<pre><code>/* hide the admin bar */
#wpadminbar { display:none; }</code></pre>
<h3 id="disable-for-non-admins">Disable the Admin Bar for non-Admins only</h3>
<p>Expanding on the previous example, here are two snippets that disable the Admin Bar for non-Admins and Editors. Place either of the following in <code>functions.php</code>:</p>
<pre><code>// show admin bar only for admins
if (!current_user_can('manage_options')) {
	add_filter('show_admin_bar', '__return_false');
}
// show admin bar only for admins and editors
if (!current_user_can('edit_posts')) {
	add_filter('show_admin_bar', '__return_false');
}</code></pre>
<p>As you might guess, any setting may be used for <code>current_user_can()</code>, so it’s easy to show/hide the Admin Bar for any particular group of users.</p>
<h3 id="clean-profile">Clean up User Profile Page</h3>
<p>After disabling the Admin Bar, you may want to hide its display settings in each user’s Profile Page. The easiest way to do this is with a simple function:</p>
<pre><code>function hideAdminBar() { ?&gt;
&lt;style type="text/css"&gt;.show-admin-bar { display: none; }&lt;/style&gt;
&lt;?php }
add_action('admin_print_scripts-profile.php', 'hideAdminBar');</code></pre>
<p>Just place that in your theme&#8217;s <code>functions.php</code> and you&#8217;re good to go. No more Admin Bar Settings displayed in the Admin area.</p>
<h3 id="always-show">Always show the Admin Bar</h3>
<p><a href="http://blog.ftwr.co.uk/archives/2011/01/05/always-show-admin-bar/" title="Always show admin bar">Follow the white rabbit</a> shows us how to show the Admin Bar even when logged out. As a bonus, a handy &#8220;Log in&#8221; button is added to the bar for easy maneuvering. Just add the following snippet to your theme&#8217;s <code>functions.php</code> file:</p>
<pre><code>// always show admin bar
function pjw_login_adminbar( $wp_admin_bar) {
	if ( !is_user_logged_in() )
	$wp_admin_bar-&gt;add_menu( array( 'title' =&gt; __( 'Log In' ), 'href' =&gt; wp_login_url() ) );
}
add_action( 'admin_bar_menu', 'pjw_login_adminbar' );
add_filter( 'show_admin_bar', '__return_true' , 1000 );</code></pre>
<p>You can see it in action at <a href="http://blog.ftwr.co.uk/archives/2011/01/05/always-show-admin-bar/" title="Always show admin bar">follow the white rabbit</a>.</p>
<h3 id="move-to-bottom">Move the Admin Bar to the bottom</h3>
<p>Want to display the Admin Bar at the bottom of the page instead of the top? <a href="http://wpengineer.com/2190/move-wordpress-admin-bar-to-the-bottom/" title="Move WordPress Admin Bar to the Bottom">WPengineer</a> shows us how with this bit of <abbr title="Cascading Style Sheets">CSS</abbr> via the <code>functions.php</code> file:</p>
<pre><code>// move admin bar to bottom
function fb_move_admin_bar() { ?&gt;
	&lt;style type="text/css"&gt;
		body {
			margin-top: -28px;
			padding-bottom: 28px;
		}
		body.admin-bar #wphead {
			padding-top: 0;
		}
		body.admin-bar #footer {
			padding-bottom: 28px;
		}
		#wpadminbar {
			top: auto !important;
			bottom: 0;
		}
		#wpadminbar .quicklinks .menupop ul {
			bottom: 28px;
		}
	&lt;/style&gt;
&lt;?php }
// on backend area
add_action( 'admin_head', 'fb_move_admin_bar' );
// on frontend area
add_action( 'wp_head', 'fb_move_admin_bar' );</code></pre>
<p>This code adds the required CSS to both the front-end (public pages) and back-end (admin pages). To disable for one or the other, just comment-out or remove the corresponding <code>add_action()</code> line near the end of the code. You could also just copy/paste the CSS into your theme&#8217;s <code>style.css</code> file if you only need to move it on the front-end of your site. An even easier way is provided by Coen Jacobs&#8217; <a href="http://cnjcbs.com/wordpress-plugins/stick-admin-bar-to-bottom/">Stick Admin Bar To Bottom</a> plugin that makes it happen automagically.</p>
<h3 id="add-remove-links">Add or Remove links from the Admin Bar</h3>
<p><a href="http://wpmu.org/how-to-add-or-remove-links-from-the-wordpress-3-1-admin-bar/" title="How to Add or Remove Links From the WordPress 3.1 Admin Bar">WPMU.org</a> shows us how to add/remove links from the Admin Bar. This is especially useful for MultiSite networks, where all of the extra links may not be necessary. The following code may be used to <strong>remove</strong> links and/or menus (via <code>functions.php</code>:</p>
<pre><code>// remove links/menus from the admin bar
function mytheme_admin_bar_render() {
	global $wp_admin_bar;
	$wp_admin_bar-&gt;remove_menu('comments');
}
add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );</code></pre>
<p>For this example, we use <code>remove_menu('comments')</code> to remove the comments dropdown list. To remove a different link/menu, check <code>/wp-includes/admin-bar.php</code> for the corresponding ID. Here&#8217;s a list of some of them to get you started:</p>
<ul>
<li><code>my-account</code> &ndash; link to your account (avatars disabled)</li>
<li><code>my-account-with-avatar</code> &ndash; link to your account (avatars enabled)</li>
<li><code>my-blogs</code> &ndash; the &#8220;My Sites&#8221; menu if the user has more than one site</li>
<li><code>get-shortlink</code> &ndash; provides a Shortlink to that page</li>
<li><code>edit</code> &ndash; link to the Edit/Write-Post page</li>
<li><code>new-content</code> &ndash; link to the &#8220;Add New&#8221; dropdown list</li>
<li><code>comments</code> &ndash; link to  the &#8220;Comments&#8221; dropdown</li>
<li><code>appearance</code> &ndash; link to the &#8220;Appearance&#8221; dropdown</li>
<li><code>updates</code> &ndash; the &#8220;Updates&#8221; dropdown</li>
</ul>
<p>To <strong>add</strong> links/menus to the Admin Bar, add the following code to your <code>functions.php</code> file:</p>
<pre><code>// add links/menus to the admin bar
function mytheme_admin_bar_render() {
	global $wp_admin_bar;
	$wp_admin_bar-&gt;add_menu( array(
		'parent' =&gt; 'new-content', // use 'false' for a root menu, or pass the ID of the parent menu
		'id' =&gt; 'new_media', // link ID, defaults to a sanitized title value
		'title' =&gt; __('Media'), // link title
		'href' =&gt; admin_url( 'media-new.php') // name of file
		'meta' =&gt; false // array of any of the following options: array( 'html' =&gt; '', 'class' =&gt; '', 'onclick' =&gt; '', target =&gt; '', title =&gt; '' );
	));
}
add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );</code></pre>
<p>You&#8217;ll want to adjust the parameters to fit your needs, and don&#8217;t forget to see the <a href="http://codex.wordpress.org/Function_Reference/add_menu" title="WP Codex: Function Reference/add menu">Codex</a> for additional information. For even more insight into this technique, see WPengineer&#8217;s post on <a href="http://wpengineer.com/2113/add-menus-to-the-admin-bar-of-wordpress/">adding menus to the Admin Bar</a>.</p>
<h3 id="admin-bar-plugins">Disable and Customize the Admin Bar with Plugins</h3>
<p>Almost immediately after the Admin Bar was added to the WordPress core, plugins started popping up to disable it, move it, minimize it, and more. Here’s a quick list of plugins and links for ultimate control over the Admin Bar.</p>
<ul>
<li><a href="http://digwp.com/u/542">Admin Bar Disabler</a></li>
<li><a href="http://digwp.com/u/543">Admin Bar Minimiser</a></li>
<li><a href="http://digwp.com/u/544">Admin Bar Removal</a></li>
<li><a href="http://digwp.com/u/545">Global Hide/Remove Admin Bar Plugin</a></li>
<li><a href="http://digwp.com/u/546">Hide Admin Bar Search</a></li>
<li><a href="http://digwp.com/u/547">Stick Admin Bar To Bottom</a></li>
<li><a href="http://digwp.com/u/548">WP Custom Admin Bar</a></li>
</ul>
<p>If you know of others, mention them in the comments and we&#8217;ll add them to the list!</p>
<h3 id="admin-bar-resources">More Admin-Bar Resources</h3>
<p>Here are some excellent resources for more information on the WordPress Admin Bar.</p>
<ul>
<li><a href="http://codex.wordpress.org/Administration_Menus">WP Codex: Administration Menus</a></li>
<li><a href="http://codex.wordpress.org/Function_Reference/add_menu" title="WP Codex: Function Reference/add menu">WP Codex: Function Reference/add menu</a></li>
<li><a href="http://yoast.com/disable-wp-admin-bar/">How to disable the WordPress Admin Bar</a></li>
<li><a href="http://www.wpbeginner.com/wp-tutorials/what-everybody-ought-to-know-about-the-wordpress-admin-bar/">What Everybody Ought to Know about the WordPress Admin Bar</a></li>
</ul>
<hr />
<p><small>© 2011 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2011/04/admin-bar-tricks/">Permalink</a> | <a href="http://digwp.com/2011/04/admin-bar-tricks/#comments">20 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2011/04/admin-bar-tricks/&title=Admin Bar Tricks">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/admin/" rel="tag">Admin</a>, <a href="http://digwp.com/tag/admin-bar/" rel="tag">admin-bar</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2011/04/admin-bar-tricks/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>What to do when Auto-Update Fails</title>
		<link>http://digwp.com/2011/04/wordpress-auto-updates/</link>
		<comments>http://digwp.com/2011/04/wordpress-auto-updates/#comments</comments>
		<pubDate>Mon, 11 Apr 2011 15:42:17 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[Upgrade]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[updates]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=4023</guid>
		<description><![CDATA[Ahh yeah, WordPress just rolled out another update to version 3.1.1. If you&#8217;re able to upgrade via the Admin, updating your site(s) should be a piece of cake: just log in, click a few buttons, wait a few minutes, and done. The convenience of automatically updating the WordPress core, plugins, and themes is awesome, but [...]]]></description>
			<content:encoded><![CDATA[<p>Ahh yeah, WordPress just rolled out another update to version 3.1.1. If you&#8217;re able to upgrade via the Admin, updating your site(s) should be a piece of cake: just log in, click a few buttons, wait a few minutes, and done. The convenience of automatically updating the WordPress core, plugins, and themes is awesome, but things can go wrong once in awhile and auto-updates can fail. If this happens, getting back on track is a bit tricky, so here&#8217;s a quick guide to help restore site functionality and ensure a proper update.</p>
<p><span id="more-4023"></span></p>
<h3>What an auto-update failure looks like</h3>
<p>After initiating the auto-update of the WordPress core (say, from 3.1.0 to 3.1.1), the &#8220;Update WordPress&#8221; screen will begin displaying the status of each step, beginning with these messages:</p>
<ul>
<li>Downloading update from <code>http://wordpress.org/wordpress-3.1.1.zip</code>&#8230;</li>
<li>Unpacking the update&#8230;</li>
<li>Verifying the unpacked files&#8230;</li>
<li>Installing the latest version&#8230;</li>
</ul>
<p>So far so good, but even if it gets that far, there&#8217;s still a chance of failure, as seen in this recent screenshot:</p>
<p><img src="http://digwp.com/wp-content/blog-images/auto-update-fail.gif" alt="[ Screenshot: Auto-Update Failure ]" /></p>
<p>The status message that appears just before &#8220;Installation Failed&#8221; explains what WordPress <em>thinks</em> is the issue, but there are cases where things go wrong and <em>no messages are displayed</em>. In either case, the user can get <strong>locked out</strong> of the site. When this happens, trying to load any of your pages &ndash; admin, blog, login, etc. &ndash; gets you the nothing but the <strong>WordPress maintenance page</strong>:</p>
<blockquote><p>Briefly unavailable for scheduled maintenance.<br />Check back in a minute.</p></blockquote>
<p>Very frustrating, and very difficult to fix things when you can&#8217;t log in to Admin. Fortunately, you don&#8217;t need Admin to fix it and get back in. Just FTP your way to the root directory and <strong>delete</strong> the <code>.maintenance</code> file. The name begins with a dot, so if you don&#8217;t see it using your FTP program, try logging into your server&#8217;s control panel and using the file manager to find and delete. Here is a screenshot showing the <code>.maintenance</code> file in the root installation directory:</p>
<p><img src="http://digwp.com/wp-content/blog-images/auto-update-file.gif" alt="[ Screenshot: The '.maintenance' File ]" /></p>
<p>This file contains a variable that is used by the <code>wp_maintenance</code> function. It looks like this: </p>
<p><code>&lt;?php $upgrading = 1302115706; ?&gt;</code></p>
<p>If you get locked out of your site, deleting the <code>.maintenance</code> file will fix the issue and get you back into Admin and other areas of your site. Once there, WordPress may remind you of the recent update failure by displaying the following message:</p>
<blockquote><p>An automated WordPress update has failed to complete &#8211; please attempt the update again now.</p></blockquote>
<p><img src="http://digwp.com/wp-content/blog-images/auto-update-fail-message.gif" alt="[ Screenshot: Auto-Update 'Fail' Message ]" /></p>
<p>At this point, you have (at least) two choices: keep trying with auto-updates or download the latest version and upload manually. Even if you decide to upgrade manually, you may want to resolve the issue and get auto-updates working for future versions.</p>
<h3>Check File Permissions</h3>
<p>Proper file permissions are the <strong>key</strong> to smooth auto-<em>anything</em>. On the Codex Page for the <a href="http://codex.wordpress.org/Dashboard_Updates_SubPanel#Troubleshooting">Dashboard Updates SubPanel</a>, the <strong>Troubleshooting</strong> section advises the following:</p>
<blockquote><p>Make sure that your entire wordpress directory is owned by the username under which your Apache server runs. For example, if your server runs as https, and your files live in /var/wordpress do a &#8220;chown -R apache.apache /var/wordpress.&#8221;</p></blockquote>
<p>In addition to this advice, you may also try changing the permissions of your <code>/upgrade/</code> directory. As seen in the following screenshot, WordPress uses the <code>/upgrade/</code> directory for a temporary file used during the installation process:</p>
<p><img src="http://digwp.com/wp-content/blog-images/auto-update-tmp.gif" alt="[ Screenshot: Upgrade Folder with Temp WP File ]" /></p>
<p>For the temporary WordPress file to be created, the <code>/upgrade/</code> directory needs to be writable by the server. To see if this is the issue, try setting the directory permissions to <code>777</code> (or CHMOD equivalent) and trying the auto-update again. If it works, you&#8217;ve resolved the issue, but you should always use the most restrictive permissions possible. This may take some research, experimenting, and/or a Help ticket with your host, but once you get it, you&#8217;re all set for auto-updates. Here is an <a href="http://www.onlineconversion.com/html_chmod_calculator.htm">Online CHMOD Calculator</a> to help with the conversion process.</p>
<h3>Turn Off Safe Mode</h3>
<p>If possible, disabling <a href="http://php.net/manual/en/features.safe-mode.php" title="PHP Safe Mode">Safe Mode</a> may help to get auto-updates working again. According to the PHP Manual, Safe Mode is deprecated as of PHP version 5.3.0:</p>
<blockquote><p>This feature has been DEPRECATED as of PHP 5.3.0.<br />Relying on this feature is highly discouraged.</p></blockquote>
<p>Disabling Safe Mode is done in a variety of ways. If disabling through your server&#8217;s control panel isn&#8217;t possible, you can use this snippet in your <code>php.ini</code> file:</p>
<pre><code>safe_mode = Off</code></pre>
<p>Or this snippet in your Apache configuration file:</p>
<pre><code>&lt;Directory /var/www/public&gt;
 php_admin_flag safe_mode off
&lt;/Directory&gt;</code></pre>
<p>Just add that code to your <code>httpd.conf</code> file and restart Apache.</p>
<h3>Define FTP Variables in wp-config.php</h3>
<p><a href="http://digwp.com/2010/11/ftp-in-wpconfig/" title="Putting FTP Info in wp-config.php to Ease Updates">As discussed</a>, another way to get auto-updates working is to define the requisite variables in your <a href="http://digwp.com/2010/08/pimp-your-wp-config-php/" title="Pimp your wp-config.php">wp-config.php file</a>. There are <a href="http://wordpress.org/support/topic/upgrade-tries-to-write-to-root" title="WP Forums: Upgrade tries to write to root">numerous</a> <a href="http://wordpress.org/support/topic/download-failed-could-not-create-temporary-file" title="WP Forums: Download failed.: Could not create Temporary file">variations</a> on this technique, so you&#8217;ll need to do your own experimentation to get a set of definitions that work for your situation. Here is what works for me on Media Temple&#8217;s (dv) server:</p>
<pre><code>define('FS_CHMOD_FILE', 0755);
define('FS_CHMOD_DIR', 0755);
define('FS_METHOD', 'ftpext');
define('FTP_BASE', '/httpdocs/');
define('FTP_CONTENT_DIR', '/httpdocs/wp-content/');
define('FTP_PLUGIN_DIR ', '/httpdocs/wp-content/plugins/');
define('FTP_USER', 'username');
define('FTP_PASS', 'password');
define('FTP_HOST', '123.456.789');
define('FTP_SSL', false);</code></pre>
<p>Place that in your <code>wp-config.php</code> file, just above the line that says, &#8220;That&#8217;s all, stop editing! Happy blogging.&#8221; Don&#8217;t forget to edit the username, password, and any other variables with your own information.</p>
<p>If you&#8217;re asking yourself why bother with all of this information, it&#8217;s because WordPress auto-updates features is SO awesome that it&#8217;s worth resolving any issues to get it working. Together with automatic plugin and theme updates, auto-WordPress updates have saved us many hours of work. For some sites, auto-updates works perfectly, for others, not so much. Just remember what you&#8217;re playing for here &ndash; it looks like this and will make keeping up with WordPress updates a much more enjoyable experience.</p>
<p><img src="http://digwp.com/wp-content/blog-images/auto-updates-success.gif" alt="[ Screenshot: Auto-Update Success ]" /></p>
<hr />
<p><small>© 2011 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2011/04/wordpress-auto-updates/">Permalink</a> | <a href="http://digwp.com/2011/04/wordpress-auto-updates/#comments">13 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2011/04/wordpress-auto-updates/&title=What to do when Auto-Update Fails">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/tips/" rel="tag">tips</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a>, <a href="http://digwp.com/tag/updates/" rel="tag">updates</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2011/04/wordpress-auto-updates/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Display Total Number of Blogroll Bookmarks</title>
		<link>http://digwp.com/2010/11/show-total-number-blogroll-bookmarks/</link>
		<comments>http://digwp.com/2010/11/show-total-number-blogroll-bookmarks/#comments</comments>
		<pubDate>Thu, 04 Nov 2010 16:32:56 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[blogroll]]></category>
		<category><![CDATA[bookmarks]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=3058</guid>
		<description><![CDATA[Quick WordPress tip for you today! A reader recently asked about displaying the total number of blogroll bookmarks on their site. This sounds simple enough but not everyone meddles with code these days, so here is a nice PHP snippet that will do the job: &#60;?php $numlinks = $wpdb-&#62;get_var("SELECT COUNT(*) FROM $wpdb-&#62;links WHERE link_visible = [...]]]></description>
			<content:encoded><![CDATA[<p>Quick WordPress tip for you today! A reader recently asked about displaying the total number of blogroll bookmarks <a href="http://www.blogschau.de/" title="blogschau.de">on their site</a>. This sounds simple enough but not everyone meddles with code these days, so here is a nice <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> snippet that will do the job:</p>
<p><span id="more-3058"></span></p>
<pre><code>&lt;?php $numlinks = $wpdb-&gt;get_var("SELECT COUNT(*) FROM $wpdb-&gt;links WHERE link_visible = 'Y'");
if (0 &lt; $numlinks) $numlinks = number_format($numlinks); ?&gt;</code></pre>
<p>Place that in your theme file and then customize the output by placing <code>&lt;?php echo $numlinks; ?&gt;</code> wherever you would like to display the results.</p>
<p>A perfect example of this code in use can be seen at <a href="http://www.blogschau.de/" title="blogschau.de">this random bookmark site</a>.</p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/11/show-total-number-blogroll-bookmarks/">Permalink</a> | <a href="http://digwp.com/2010/11/show-total-number-blogroll-bookmarks/#comments">3 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/11/show-total-number-blogroll-bookmarks/&title=Display Total Number of Blogroll Bookmarks">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/blogroll-2/" rel="tag">blogroll</a>, <a href="http://digwp.com/tag/bookmarks/" rel="tag">bookmarks</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/11/show-total-number-blogroll-bookmarks/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Speed Up Your Blogging with WordPress Shortcodes</title>
		<link>http://digwp.com/2010/09/speed-up-blogging-wordpress-shortcodes/</link>
		<comments>http://digwp.com/2010/09/speed-up-blogging-wordpress-shortcodes/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 16:16:02 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[shortcodes]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://diggingintowordpress.com/?p=87</guid>
		<description><![CDATA[Save time by replacing your most commonly typed words and phrases with WordPress shortcodes. For example, if you are frequently typing your blog&#8217;s URL, you could place the following code your theme&#8217;s functions.php file: function shortURL() { return 'http://your-site.com/'; } add_shortcode('myurl', 'shortURL'); Now whenever you write a post in &#8220;HTML-mode&#8221;, you can include your blog&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Save time by replacing your most commonly typed words and phrases with WordPress shortcodes. For example, if you are frequently typing your blog&rsquo;s <acronym title="Uniform Resource Locator">URL</acronym>, you could place the following code your theme&rsquo;s <code>functions.php</code> file:</p>
<pre><code>function shortURL() {
	return 'http://your-site.com/';
}
add_shortcode('myurl', 'shortURL');</code></pre>
<p>Now whenever you write a post in &ldquo;<acronym title="Hypertext Markup Language">HTML</acronym>-mode&rdquo;, you can include your blog&rsquo;s <acronym title="Uniform Resource Locator">URL</acronym> at breakneck speed by simply typing &ldquo;<code>[myurl]</code>&rdquo;. Works great in WordPress 2.5 or better.</p>
<p><span id="more-87"></span></p>
<p><strong>Shortcodes for your favorite links</strong><br />To create a shortcode for your favorite links, we need to include the <code>href</code> attribute information as well as the anchor text for the link itself. We can do this by placing this function in your theme&rsquo;s <code>functions.php</code> file:</p>
<pre><code>function shortLink($atts, $content = null) {
	extract(shortcode_atts(array(
		"href" =&gt; 'http://default-website.com' // default URL
	), $atts));
	return '&lt;a href="'.$href.'"&gt;'.$content.'&lt;/a&gt;';
}
add_shortcode('link', 'shortLink');</code></pre>
<p>Then, when creating a post, emulate the following format to include any links you wish:</p>
<p><code>[link href="http://your-site.com/"]Your Website![/link]</code></p>
<p>..which will output the following code:</p>
<p><code>&lt;a href="http://your-site.com/"&gt;Your Website!&lt;/a&gt;</code></p>
<p>When the <code>href</code> attribute is removed from the shortcode, the default <acronym title="Uniform Resource Locator">URL</acronym> will be used. You may specify the default <acronym title="Uniform Resource Locator">URL</acronym> in the third line of the function (see comment). This makes it easy to add a complete link to your site on the fly by simply typing:</p>
<p><code>[link]Your Website![/link]</code></p>
<p>One of the nice things about using shortcodes instead of hard-coded links is that you can easily change the default <abbr title="Uniform Resource Locator">URL</abbr> without breaking anything.</p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/09/speed-up-blogging-wordpress-shortcodes/">Permalink</a> | <a href="http://digwp.com/2010/09/speed-up-blogging-wordpress-shortcodes/#comments">6 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/09/speed-up-blogging-wordpress-shortcodes/&title=Speed Up Your Blogging with WordPress Shortcodes">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/shortcodes/" rel="tag">shortcodes</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/09/speed-up-blogging-wordpress-shortcodes/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

