<?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; functions</title>
	<atom:link href="http://digwp.com/tag/functions/feed/" rel="self" type="application/rss+xml" />
	<link>http://digwp.com</link>
	<description>Take your WordPress skills to the next level.</description>
	<lastBuildDate>Thu, 09 Feb 2012 19:03:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Displaying Theme Data with WordPress</title>
		<link>http://digwp.com/2011/12/displaying-theme-data-with-wordpress/</link>
		<comments>http://digwp.com/2011/12/displaying-theme-data-with-wordpress/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 18:36:29 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

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

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

    $theme_name = 'twentyeleven'; 

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

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

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

		<guid isPermaLink="false">http://digwp.com/?p=5179</guid>
		<description><![CDATA[WordPress makes it easy to publish content in any number of categories, with any number of tags, and with any type of custom post format. So for example, in addition to full articles, you could also offer screencasts, links, side posts, tweets, and all sorts of other peripheral content. Complementary material may work great for [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress makes it easy to publish content in any number of categories, with any number of tags, and with any type of custom post format. So for example, in addition to full articles, you could also offer screencasts, links, side posts, tweets, and all sorts of other peripheral content. Complementary material may work great for visitors surfing around your site, but including all of that extra stuff in your RSS feed dilutes the potency of your main articles. The idea here is that your visitors will subscribe to the more <em>focused</em> content.</p>
<p><span id="more-5179"></span></p>
<p>In this post, we create a custom, &#8220;articles-only&#8221; feed for visitors who want to subscribe to the main content only, without all the side stuff. The technique is actually pretty flexible, and works great to create just about <em>any</em> type of custom WordPress feed content. It&#8217;s pretty easy to do, requiring a whopping two steps to make it happen..</p>
<h3>Step 1: Create the custom page template</h3>
<p>Go to your theme directory and create a new <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> file named <code>article-feed.php</code>. Then add the following code (don&#8217;t worry it&#8217;s actually not that bad):</p>
<pre><code>&lt;?php 
/* 
Template Name: Article Feed
*/
$numposts = 10; // number of posts in feed
$posts = query_posts('showposts='.$numposts.'&amp;cat=3');
$more = 1;

header('Content-Type: '.feed_content_type('rss-http').'; charset='.get_option('blog_charset'), true);
echo '&lt;?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'&gt;';
?&gt;

&lt;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/"
	&lt;?php do_action('rss2_ns'); ?&gt;
&gt;
&lt;channel&gt;
	&lt;title&gt;&lt;?php bloginfo_rss('name'); wp_title_rss(); ?&gt; - Article Feed&lt;/title&gt;
	&lt;atom:link href="&lt;?php self_link(); ?&gt;" rel="self" type="application/rss+xml" /&gt;
	&lt;link&gt;&lt;?php bloginfo_rss('url') ?&gt;&lt;/link&gt;
	&lt;description&gt;&lt;?php bloginfo_rss("description") ?&gt;&lt;/description&gt;
	&lt;lastBuildDate&gt;&lt;?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?&gt;&lt;/lastBuildDate&gt;
	&lt;?php the_generator( 'rss2' ); ?&gt;
	&lt;language&gt;&lt;?php echo get_option('rss_language'); ?&gt;&lt;/language&gt;
	&lt;sy:updatePeriod&gt;&lt;?php echo apply_filters( 'rss_update_period', 'hourly' ); ?&gt;&lt;/sy:updatePeriod&gt;
	&lt;sy:updateFrequency&gt;&lt;?php echo apply_filters( 'rss_update_frequency', '1' ); ?&gt;&lt;/sy:updateFrequency&gt;
	&lt;?php do_action('rss2_head'); ?&gt;
	&lt;?php while( have_posts()) : the_post(); ?&gt;

	&lt;item&gt;
		&lt;title&gt;&lt;?php the_title_rss(); ?&gt;&lt;/title&gt;
		&lt;link&gt;&lt;?php the_permalink_rss(); ?&gt;&lt;/link&gt;
		&lt;comments&gt;&lt;?php comments_link(); ?&gt;&lt;/comments&gt;
		&lt;pubDate&gt;&lt;?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?&gt;&lt;/pubDate&gt;
		&lt;dc:creator&gt;&lt;?php the_author(); ?&gt;&lt;/dc:creator&gt;
&lt;?php the_category_rss(); ?&gt;
		&lt;guid isPermaLink="false"&gt;&lt;?php the_guid(); ?&gt;&lt;/guid&gt;
&lt;?php if (get_option('rss_use_excerpt')) : ?&gt;

		&lt;description&gt;&lt;![CDATA[&lt;?php the_excerpt_rss() ?&gt;]]&gt;&lt;/description&gt;
&lt;?php else : ?&gt;

		&lt;description&gt;&lt;![CDATA[&lt;?php the_excerpt_rss() ?&gt;]]&gt;&lt;/description&gt;
	&lt;?php if ( strlen( $post-&gt;post_content ) &gt; 0 ) : ?&gt;

		&lt;content:encoded&gt;&lt;![CDATA[&lt;?php the_content() ?&gt;]]&gt;&lt;/content:encoded&gt;
	&lt;?php else : ?&gt;

		&lt;content:encoded&gt;&lt;![CDATA[&lt;?php the_excerpt_rss() ?&gt;]]&gt;&lt;/content:encoded&gt;
	&lt;?php endif; ?&gt;
&lt;?php endif; ?&gt;

		&lt;wfw:commentRss&gt;&lt;?php echo get_post_comments_feed_link(); ?&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>This is basically just a typical WordPress feed template, but with some extra query action to make it do what we want. In the first few lines of code, we specify how many posts to display, which categories to include, and whether to display full posts or excerpts:</p>
<pre><code>$numposts = 10; // number of posts in feed
$posts = query_posts('showposts='.$numposts.'&amp;cat=3');
$more = 1;</code></pre>
<p>Using this default code, the custom feed will show 10 posts from category 3. And with <code>$more</code> set to <code>1</code>, the <em>full</em> article will be included in the feed. This is where you customize your new feed to include whatever you want. So for example, if we post articles in three different categories, say with IDs of <code>1</code>, <code>2</code>, and <code>3</code>, we would modify our code to look like this:</p>
<pre><code>$numposts = 10; // number of posts in feed
$posts = query_posts('showposts='.$numposts.'&amp;cat=1,2,3');
$more = 1;</code></pre>
<p>The <code>query_posts</code> function is quite flexible and provides all of the parameters needed to set up just about any customized feed content. You can exclude/include categories, display specific types of posts, change the number of posts displayed, and so much more. For a full list of options, check out <a href="http://codex.wordpress.org/Function_Reference/query_posts">query_posts at the WordPress Codex</a>.</p>
<h3>Step 2: Create the custom Page in the WP Admin</h3>
<p>Once you have the custom Page Template uploaded to your server, log into the WordPress Admin and visit the &#8220;Add New Page&#8221; screen (<strong>Pages &gt; Add New</strong>). Create a new page named &#8220;Articles-Only Feed&#8221; (or whatever), and select the newly added &#8220;articles&#8221; page template from the drop-down menu:</p>
<p><img src="http://digwp.com/wp-content/blog-images/articles-only-template.gif" alt="" /></p>
<p>While you&#8217;re there in the Admin creating this new custom-feed page, take a moment to be mindful of the feed <abbr title="Uniform Resource Locator">URL</abbr> and title, which may be set to whatever works best:</p>
<p><img src="http://digwp.com/wp-content/blog-images/articles-only-page.gif" alt="" /></p>
<p>Once everything is ready, finish it up by publishing the page to your site. Then check that your new feed is working by visiting the URL of the new page you just created in the WP Admin. Here at <a href="http://digwp.com/">DigWP.com</a>, our articles-only feed is available at <a href="http://digwp.com/articles/" title="DigWP.com - Articles Feed"><code>http://digwp.com/articles/</code></a>.</p>
<h3>Wrap-up + additional resources</h3>
<p>In addition to the easy-breezy two-step custom-feed tutorial in this post, here are some additional resources that are sort of related to this general topic:</p>
<ul>
<li><a href="http://digwp.com/2011/04/tumblr-links-post-formats/">Tumblr Links with Post Formats</a></li>
<li><a href="http://digwp.com/2009/09/easy-custom-feeds-in-wordpress/">Easy Custom Feeds in WordPress</a></li>
<li><a href="http://digwp.com/2009/09/tumblr-style-links-for-posts-and-feeds/">How to Implement Tumblr-Style Links for Posts and Feeds</a></li>
</ul>
<hr />
<p><small>© 2011 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2011/08/custom-feeds/">Permalink</a> | <a href="http://digwp.com/2011/08/custom-feeds/#comments">12 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2011/08/custom-feeds/&title=Create an Articles-Only Feed">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/php/" rel="tag">PHP</a>, <a href="http://digwp.com/tag/query_posts/" rel="tag">query_posts</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2011/08/custom-feeds/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Tumblr Links with Post Formats</title>
		<link>http://digwp.com/2011/04/tumblr-links-post-formats/</link>
		<comments>http://digwp.com/2011/04/tumblr-links-post-formats/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 17:49:20 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[post-formats]]></category>
		<category><![CDATA[Theme]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=3865</guid>
		<description><![CDATA[With WordPress 3.1&#8217;s new Post Format functionality, it&#8217;s easier than ever to create your own Tumblr-style Link posts. We do this right here at DigWP.com using our own hand-rolled method. Scroll through a page or two of the site&#8217;s most recent posts, and you&#8217;ll see that Link posts are formatted and styled differently than regular [...]]]></description>
			<content:encoded><![CDATA[<p>With WordPress 3.1&rsquo;s new <strong>Post Format</strong> functionality, it&rsquo;s easier than ever to create your own <strong>Tumblr-style Link posts</strong>. We do this right here at <a href="http://digwp.com/">DigWP.com</a> using our own <a href="http://digwp.com/2009/09/tumblr-style-links-for-posts-and-feeds/" title="How to Implement Tumblr-Style Links for Posts and Feeds">hand-rolled method</a>. Scroll through a page or two of the site&rsquo;s most recent posts, and you&rsquo;ll see that <strong>Link posts</strong> are formatted and styled differently than regular posts (see screenshot below). In this tutorial, you&#8217;ll learn how to use <strong>WordPress&#8217; new Post Formats</strong> to setup your own <strong>Tumblr-style Links</strong> in <em>3 easy steps</em>.</p>
<p><span id="more-3865"></span></p>
<p><img src="http://digwp.com/wp-content/blog-images/post-formats-digwp-links.gif" alt="[ Screenshot: Link Posts at DigWP.com ]" /></p>
<p>Link posts are meant for quick links to <em>external</em> resources. Ideally, they&#8217;re styled for easy recognition without breaking the flow of post content. Link posts look like link posts, Asides look like asides, Galleries look like galleries, and so on. Here&#8217;s a chart showing the differences between <em>regular posts</em> and <em>Link posts</em>:</p>
<p><img src="http://digwp.com/wp-content/blog-images/post-formats-compare.gif" alt="[ Regular vs Link Posts ]" /></p>
<p>Notice the <strong>key difference</strong> between the two types of posts: <strong>regular post titles</strong> link to the <em>single-view</em> of the post, but <strong>Link post titles</strong> link to the <abbr title="Uniform Resource Locator">URL</abbr> of an <em>external resource</em> (i.e., whatever awesome thing you&#8217;re sharing with your visitors). This makes it super-easy to share links via <em>true</em> &#8220;Tumblr-style&#8221; Link posts. And with WordPress 3.1&rsquo;s new <strong>Post Formats</strong> functionality, it&#8217;s <em>easier than ever</em> to do.</p>
<h3>Easy, 3-Step Tutorial</h3>
<p>Here&#8217;s an overview of the tutorial:</p>
<ol>
<li><a href="#step1">Enable Post Formats via <code>functions.php</code></a></li>
<li><a href="#step2">Include the conditional template tags in your theme files</a></li>
<li><a href="#step3">Style with some <abbr title="Cascading Style Sheets">CSS</abbr> via <code>style.css</code> (optional)</a></li>
<li><a href="#usage">Usage and notes</a></li>
</ol>
<p>Even if you don&#8217;t implement this technique, the tutorial provides a great example of how Post Formats can be used to add variety and depth to any WordPress-powered site.</p>
<h3 id="step1">Step 1: Enable Post Formats</h3>
<p>First, make sure you have the latest version of WordPress (3.1 or better), and then <strong>enable Post Formats</strong> by adding this snippet to your theme&#8217;s <code>functions.php</code> file:</p>
<pre><code>// Enable Post Formats for WP 3.1+
add_theme_support('post-formats',array('aside','chat','gallery','image','link','quote','status','video','audio'));</code></pre>
<p>With that in place, all nine (+1 default) Post Formats will be enabled on your site. Next time you write or edit a post, you should see a <strong>Post Formats</strong> panel with options for each of these different formats. If you know you won&#8217;t be needing some of them, feel free to edit the parameter list in the code snippet. Otherwise, it&#8217;s totally fine to leave them all enabled &ndash; it doesn&#8217;t hurt anything &ndash; it&#8217;s just a matter of preference.</p>
<h3 id="step2">Step 2: Customize your theme files</h3>
<p>Next, in your theme&#8217;s template file(s), replace the markup/tags used to generate your post titles (located in the loop) with the following conditional code: </p>
<pre><code>&lt;?php if (has_post_format('link') &amp;&amp; get_post_meta($post-&gt;ID, 'LinkFormatURL', true)) : ?&gt;
			
	&lt;h2&gt;&lt;a href="&lt;?php echo get_post_meta($post-&gt;ID, 'LinkFormatURL', true); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;
			
&lt;?php else : ?&gt;
			
	&lt;h2&gt;&lt;a href="&lt;?php the_permalink() ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;
			
&lt;?php endif; ?&gt;</code></pre>
<p>The first line tests each post using <code>has_post_format</code> and <code>get_post_meta</code>. IF the post is a <strong>Link post</strong> (has &#8220;<code>link</code>&#8221; post format) AND has an alternate URL (via &#8220;<code>LinkFormatURL</code>&#8221; custom field), the post title will be Tumblr-style <em>as specified</em> in the second line of code. If <em>both</em> of those conditions <em>fail</em>, the post title will be the regular/default, as specified in the fourth line of code. You may use any <abbr title="PHP: Hypertext Preprocessor">PHP</abbr>/markup needed to customize your Link posts to suit your design.</p>
<p><strong id="step2update">Update:</strong> <a href="http://digwp.com/2011/04/tumblr-links-post-formats/#comment-20779" title="Read comment">Matt Wiebe</a> makes this step even easier. Instead of messing with your theme files, just add this snippet to your theme&#8217;s <code>functions.php</code>:</p>
<pre><code>// filter post title for tumblr links
function sd_link_filter($link, $post) {
     if (has_post_format('link', $post) &amp;&amp; get_post_meta($post-&gt;ID, 'LinkFormatURL', true)) {
          $link = get_post_meta($post-&gt;ID, 'LinkFormatURL', true);
     }
     return $link;
}
add_filter('post_link', 'sd_link_filter', 10, 2);</code></pre>
<p>This script filters the <code>post_link</code> and returns the correct URL based on the same conditions as before. Just plug-n-play &ndash; no other theme modifications required. Thanks to <a href="http://somadesign.ca/">Matt Wiebe</a> for sharing this more elegant method.</p>
<h3 id="step3">Step 3: Style with CSS</h3>
<p>Lastly and optionally, you are encouraged to customize the appearance of your custom Post Formats. Referring back to the opening screenshot, notice how Link posts stand out as distinct and easy to recognize as such. To style your Link posts with CSS, make sure your theme includes the <code>post_class()</code> tag in the outer <code>&lt;div&gt;</code> (or whatever) for each post. The <code>post_class()</code> function will then output the Post-Format name as a class attribute for each post. This provides a nice hook for hanging your custom CSS. Here is a simple example using our code from Step 2:</p>
<pre><code>.format-standard { width: 100%; }
.format-link     { width: 75%; }

.format-standard h2 { font-size: 24px; }
.format-link h2     { font-size: 16px; }

.format-standard a { color: #000; }
.format-link a     { color: #777; }</code></pre>
<p>Using the <code>.format-{whatever}</code> class attribute, it&#8217;s easy to style each of your Post Formats with a distinct appearance that&#8217;s easy to recognize.</p>
<h3 id="usage">Usage and Notes</h3>
<p>Once you get everything setup, posting Links is as easy as 1-2-3..</p>
<ol>
<li><strong>Write</strong> your Link post</li>
<li><strong>Choose</strong> the &#8220;Link&#8221; format type from the Format radio-button menu (located under the Publish panel)</li>
<li><strong>Add</strong> the Link URL (external resource) to a custom field named &#8220;<code>LinkFormatURL</code>&#8221; (see screenshot below)</li>
</ol>
<p><img src="http://digwp.com/wp-content/blog-images/post-formats-custom-field.gif" alt="[ Screenshot: Link Post Custom Field ]" /></p>
<p>And that&#8217;s all there is to it! After posting a new Link, it will be displayed using the format and styles that you&#8217;ve applied. A few notes:</p>
<ol>
<li>CSS hooks for post-formats are available via <code>post_class()</code></li>
<li>When customizing your theme as per Step 2, don&#8217;t forget about <code>archive.php</code>, <code>category.php</code>, and any other template files that use the loop</li>
<li>This tutorial sets up Tumblr-style Links for your blog only, but you can <a href="http://digwp.com/2009/09/tumblr-style-links-for-posts-and-feeds/" title="How to Implement Tumblr-Style Links for Posts and Feeds">check this post</a> to setup the Tumblr Links for feeds as well</li>
</ol>
<p>If you have any questions about setting this up on your site, leave a comment and we&#8217;ll try to help. Also, see the &#8220;Possibly Related Posts&#8221; below for related content on this topic.</p>
<hr />
<p><small>© 2011 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2011/04/tumblr-links-post-formats/">Permalink</a> | <a href="http://digwp.com/2011/04/tumblr-links-post-formats/#comments">16 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2011/04/tumblr-links-post-formats/&title=Tumblr Links with Post Formats">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/post-formats/" rel="tag">post-formats</a>, <a href="http://digwp.com/tag/theme/" rel="tag">Theme</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2011/04/tumblr-links-post-formats/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Show Post Thumbnails in Feeds</title>
		<link>http://digwp.com/2010/06/show-post-thumbnails-in-feeds/</link>
		<comments>http://digwp.com/2010/06/show-post-thumbnails-in-feeds/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 07:05:49 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[feeds]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[thumbnails]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=2308</guid>
		<description><![CDATA[One of the nice things about using WordPress&#8217; new post-thumbnails feature is that they provide tons of flexibility in terms of where and how you display your post thumbnails. By design, post thumbnails are not included within post content, so they will not be displayed in your blog posts unless you call them specifically with [...]]]></description>
			<content:encoded><![CDATA[<p>One of the nice things about using WordPress&rsquo; new post-thumbnails feature is that they provide tons of flexibility in terms of <em>where</em> and <em>how</em> you display your post thumbnails. By design, post thumbnails are not included within post content, so they will not be displayed in your blog posts unless you call them specifically with the proper template tag:</p>
<pre><code>&lt;?php the_post_thumbnail(); ?&gt;</code></pre>
<p>When included within the loop, <code>the_post_thumbnail()</code> will output the markup for the post&rsquo;s thumbnail, linked to a full-size or pre-sized version of the image. Of course, there are a <a href="http://wpengineer.com/the-ultimative-guide-for-the_post_thumbnail-in-wordpress-2-9/" title="The Ultimative Guide For the_post_thumbnail In WordPress 2.9">few more awesome things</a> that you can do with <a href="http://codex.wordpress.org/Template_Tags/the_post_thumbnail" title="WordPress Codex: Template Tags/the_post_thumbnail">the_post_thumbnail</a>. Now that we&rsquo;ve seen how to include thumbnails in <em>post</em> content, let&rsquo;s do it for <em>feed</em> content..</p>
<p><span id="more-2308"></span></p>
<h3>Display Post Thumbnails in Feed Content</h3>
<p>To include post-thumbnails in your feeds, we need to filter WordPress&rsquo; feed functionality and inject the required template tag into both <em>feed-excerpt</em> and <em>full-feed</em> content:</p>
<pre><code>// show post thumbnails in feeds
function diw_post_thumbnail_feeds($content) {
	global $post;
	if(has_post_thumbnail($post-&gt;ID)) {
		$content = '&lt;div&gt;' . get_the_post_thumbnail($post-&gt;ID) . '&lt;/div&gt;' . $content;
	}
	return $content;
}
add_filter('the_excerpt_rss', 'diw_post_thumbnail_feeds');
add_filter('the_content_feed', 'diw_post_thumbnail_feeds');</code></pre>
<p>Include that code in your active theme&rsquo;s <code>functions.php</code> file and your feeds will display the post thumbnail <em>before</em> each post. To display the post thumbnail <em>after</em> the post content, a slight adjustment is made to the fourth line of the function:</p>
<p><code>$content = $content . '&lt;div&gt;' . get_the_post_thumbnail($post-&gt;ID) . '&lt;/div&gt;';</code></p>
<p>The <code>&lt;div&gt;</code> will prevent the post text from wrapping around the post thumbnail, but theoretically its removal would enable the post content to wrap around the image:</p>
<p><code>$content = get_the_post_thumbnail($post-&gt;ID) . $content;</code></p>
<p>As easy and flexible as it is working with <code>the_post_thumbnail()</code>, there may be situations where you need more control over the appearance and functionality of your posts&rsquo; attached images. Fortunately, <a href="http://perishablepress.com/press/2008/12/22/wordpress-custom-fields-tips-tricks/" title="WordPress Custom Fields, Part II: Tips and Tricks">WordPress&rsquo; custom fields</a> and <a href="http://digwp.com/2009/08/awesome-image-attachment-recipes-for-wordpress/" title="Awesome Image-Attachment Recipes for WordPress">image-attachment functionality</a> enable just about any custom configuration you can imagine.</p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/06/show-post-thumbnails-in-feeds/">Permalink</a> | <a href="http://digwp.com/2010/06/show-post-thumbnails-in-feeds/#comments">16 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/06/show-post-thumbnails-in-feeds/&title=Show Post Thumbnails in 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/thumbnails/" rel="tag">thumbnails</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/06/show-post-thumbnails-in-feeds/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Specify Unique CSS File Per Post</title>
		<link>http://digwp.com/2010/05/specify-unique-css-file-per-post/</link>
		<comments>http://digwp.com/2010/05/specify-unique-css-file-per-post/#comments</comments>
		<pubDate>Mon, 10 May 2010 21:20:39 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=2082</guid>
		<description><![CDATA[I&#8217;m a HUGE fan of being able to link up a CSS file on a per-page basis. I just find it extremely common that a page needs CSS styling unique to it, and I hate litering a sites main stylesheet with customizations that only one particular page needs. We&#8217;ve talked about this before, and even [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a HUGE fan of being able to link up a CSS file on a per-page basis. I just find it extremely common that a page needs CSS styling unique to it, and I hate litering a sites main stylesheet with customizations that only one particular page needs. We&#8217;ve talked about this before, and even created a <a href="http://digwp.com/2010/02/custom-css-per-post/">custom method for doing so</a>, as well as mentioned the <a href="http://wordpress.org/extend/plugins/art-direction/">art direction plugin</a>, which makes this easily possible. </p>
<p>Both of those methods are still sweet, but I find in general that I like to write my CSS in actual CSS files I keep in my theme and can edit using whatever CSS editor I like, as well as keep things clean and simple in the admin. So, I&#8217;ve altered the technique a bit.</p>
<p><span id="more-2082"></span></p>
<p>The idea is to add a simple text input to the page editor, right underneath the content area, where you can manually specify the name of a CSS file. In the image below, you can see I&#8217;ve also added one for JavaScript.</p>
<p><img src="http://digwp.com/wp-content/blog-images/customfiles.png" width="590" height="177" alt="" title="" /></p>
<p>To add this to your site, it&#8217;s just some code to add to the functions.php file. Should work for any site.</p>
<pre><code>// Custom Stylesheet box in Pages/Posts
add_action('admin_menu', 'digwp_custom_css_hooks');
add_action('save_post', 'digwp_save_custom_css');
add_action('wp_head','digwp_insert_custom_css');
function digwp_custom_css_hooks() {
	add_meta_box('custom_css', 'Name of custom CSS file', 'digwp_custom_css_input', 'post', 'normal', 'high');
	add_meta_box('custom_css', 'Name of custom CSS file', 'digwp_custom_css_input', 'page', 'normal', 'high');
}
function digwp_custom_css_input() {
	global $post;
	echo '&lt;input type="hidden" name="custom_css_noncename" id="custom_css_noncename" value="'.wp_create_nonce('custom-css').'" /&gt;';
	echo '&lt;input type="text" name="custom_css" id="custom_css" style="width:100%;" value="'.get_post_meta($post-&gt;ID,'_custom_css',true).'" /&gt;';
}
function digwp_save_custom_css($post_id) {
	if (!wp_verify_nonce($_POST['custom_css_noncename'], 'custom-css')) return $post_id;
	if (defined('DOING_AUTOSAVE') &amp;&amp; DOING_AUTOSAVE) return $post_id;
	$custom_css = $_POST['custom_css'];
	update_post_meta($post_id, '_custom_css', $custom_css);
}
function digwp_insert_custom_css() {
	if (is_page() || is_single()) {
		if (have_posts()) : while (have_posts()) : the_post();
		  $filename = get_post_meta(get_the_ID(), '_custom_css', true);
		  if ($filename) {
			echo "&lt;link rel='stylesheet' type='text/css' href='" . get_bloginfo('template_url') . "/css/" . $filename . "' /&gt;";
          }
		endwhile; endif;
		rewind_posts();
	}
}</code></pre>
<p>If you are happy with just CSS only, you can stop there. If you would like the JavaScript box as well, here is that code.</p>
<pre><code>// Custom JavaScript in Pages/Posts  (...lots of repeated code, could be better)
add_action('admin_menu', 'digwp_custom_js_hooks');
add_action('save_post', 'digwp_save_custom_js');
add_action('wp_head','digwp_insert_custom_js');
function digwp_custom_js_hooks() {
	add_meta_box('custom_js', 'Name of custom JavaScript file', 'digwp_custom_js_input', 'post', 'normal', 'high');
	add_meta_box('custom_js', 'Name of custom JavaScript file', 'digwp_custom_js_input', 'page', 'normal', 'high');
}
function digwp_custom_js_input() {
	global $post;
	echo '&lt;input type="hidden" name="custom_js_noncename" id="custom_js_noncename" value="'.wp_create_nonce('custom-js').'" /&gt;';
	echo '&lt;input type="text" name="custom_js" id="custom_js" style="width:100%;" value="'.get_post_meta($post-&gt;ID,'_custom_js',true).'" /&gt;';
}
function digwp_save_custom_js($post_id) {
	if (!wp_verify_nonce($_POST['custom_js_noncename'], 'custom-js')) return $post_id;
	if (defined('DOING_AUTOSAVE') &amp;&amp; DOING_AUTOSAVE) return $post_id;
	$custom_js = $_POST['custom_js'];
	update_post_meta($post_id, '_custom_js', $custom_js);
}
function digwp_insert_custom_js() {
	if (is_page() || is_single()) {
		if (have_posts()) : while (have_posts()) : the_post();
		    $filename = get_post_meta(get_the_ID(), '_custom_js', true);
		    if ($filename) {
			 echo "&lt;script type='text/javascript' src='" . get_bloginfo('template_url') . "/js/" . $filename . "' &gt;&lt;/script&gt;";
            }
		endwhile; endif;
		rewind_posts();
	}
}</code></pre>
<p>You could probably combine these together a bit better than I have done here, it&#8217;s a bit redundant. </p>
<h3>How it Works</h3>
<p>There are three things going on here, which tap into three existing WordPress &#8220;hooks&#8221;.</p>
<ol>
<li>Adds text inputs to the page editing screen of the admin using the <code>admin_menu</code> hook and the <code>add_meta_box</code> function</li>
<li>Save the values of those text inputs when the page is saved using the <code>save_post</code> hook</li>
<li>Output <code>&lt;link&gt;</code> or <code>&lt;script&gt;</code> tags in the <code>&lt;head&gt;</code> of the site (when those values are present) using the <code>wp_head</code> hook.</li>
</ol>
<h3>The Result</h3>
<p>If you put the value &#8220;yeahbaby.css&#8221; in that input box, when that particular page loads, you are going to get this output in the <code>&lt;head&gt;</code>:</p>
<pre><code>&lt;link rel='stylesheet' type='text/css' href='http://yoursite.com/notes/wp-content/themes/your-theme/css/yeahbaby.css' /&gt;</code></pre>
<p>&#8220;yoursite.com&#8221; will obviously be your sites domain, and your-theme will the folder in which your currently active theme resides. Do keep that in mind, as should you change themes, you&#8217;ll need to move the &#8220;css&#8221; folder in that theme that contains these custom CSS files to the new theme. </p>
<h3>UPDATE (May 13, 2010)</h3>
<p>Notice how all the function names are prefixed by &#8220;digwp_&#8221; &#8211; that is in accordance to best practices described by Andrew Nacin <a href="http://www.andrewnacin.com/2010/05/11/in-wordpress-prefix-everything/">here</a>.</p>
<p>This has also been <a href="http://wordpress.org/extend/plugins/include-custom-files/">made into a plugin</a> by <a href="http://utkar.sh/">Utkarsh Kukreti</a>. Requires PHP5.</p>
<h3>Ways This Code Could Be Improved</h3>
<p>I was holding back on publishing this because there are a lot of ways it could be better. But I had mentioned it at the <a href="http://www.cmsexpo.net/">CMS Expo</a> and there was some interested and I said I would, so I&#8217;m releasing it a bit early. Here are things that could be better&#8230;</p>
<ul>
<li>Combine the functions together to create less redundancies between the CSS and JavaScript versions.</li>
<li>Allow for a comma-separated list in case multiple custom CSS files are needed.</li>
<li>Make it a plugin instead of custom functions. Add options screen to specify file path to custom CSS folder.</li>
</ul>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/05/specify-unique-css-file-per-post/">Permalink</a> | <a href="http://digwp.com/2010/05/specify-unique-css-file-per-post/#comments">21 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/05/specify-unique-css-file-per-post/&title=Specify Unique CSS File Per Post">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/php/" rel="tag">PHP</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/05/specify-unique-css-file-per-post/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Custom Page Titles from Scratch</title>
		<link>http://digwp.com/2010/04/custom-page-titles/</link>
		<comments>http://digwp.com/2010/04/custom-page-titles/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 18:33:20 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[SEO]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[title]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1953</guid>
		<description><![CDATA[The titles of pages are controlled by the &#60;title> tag in the &#60;head> section of a website. They are important for all kinds of reasons. Telling the user where they are. The name of the page when bookmarked both locally and socially. They are important for SEO. So how do we typically handle page titles [...]]]></description>
			<content:encoded><![CDATA[<p>The titles of pages are controlled by the &lt;title> tag in the &lt;head> section of a website. They are important for all kinds of reasons. Telling the user where they are. The name of the page when bookmarked both locally and socially. They are important for SEO.  </p>
<p>So how do we typically handle page titles in WordPress? Hopefully we are A) Using a theme that uses <a href="http://digwp.com/2009/06/custom-wordpress-title-tags/">a pretty smart default page titling system</a> or B) using a plugin that helps us with this same task automatically, as most SEO plugins at least attempt.</p>
<p>The problem with A is that it doesn&#8217;t afford any way to individually override any particular page with a special title. With B, it depends on which plugin you use, but not all of them allow for <em>full</em> control over the <em>entire</em> title, often just the slug that fits into the overall chosen method.</p>
<p><img src="http://digwp.com/wp-content/blog-images/bendtomywill.jpg" width="549" height="268" alt="" title="" /></p>
<p>Finally fed up with both of these techniques, I rolled my own!</p>
<p><span id="more-1953"></span></p>
<h3>Step 1: Remove &lt;title></h3>
<p>Whatever you have for the &lt;title> tag in the header.php file, just get rid of it.</p>
<p><img src="http://digwp.com/wp-content/blog-images/removetitle.png" width="590" height="248" alt="" title="" /></p>
<p>We&#8217;ll be inserting that automatically in the wp_head(); function, so that needs to be there.</p>
<h3>Step 2: New stuff for functions.php file</h3>
<p>We&#8217;re doing three things here.</p>
<ol>
<li>Add a new input box to the admin pages for creating and editing new Posts/Pages</li>
<li>Save the the value of that input box when that Post/Page is saved</li>
<li>Echo out a new title as part of the wp_head() function</li>
</ol>
<pre><code>// Custom Page Titles
add_action('admin_menu', 'custom_title');
add_action('save_post', 'save_custom_title');
add_action('wp_head','insert_custom_title');
function custom_title() {
	add_meta_box('custom_title', 'Change page title', 'custom_title_input_function', 'post', 'normal', 'high');
	add_meta_box('custom_title', 'Change page title', 'custom_title_input_function', 'page', 'normal', 'high');
}
function custom_title_input_function() {
	global $post;
	echo '&lt;input type="hidden" name="custom_title_input_hidden" id="custom_title_input_hidden" value="'.wp_create_nonce('custom-title-nonce').'" /&gt;';
	echo '&lt;input type="text" name="custom_title_input" id="custom_title_input" style="width:100%;" value="'.get_post_meta($post-&gt;ID,'_custom_title',true).'" /&gt;';
}
function save_custom_title($post_id) {
	if (!wp_verify_nonce($_POST['custom_title_input_hidden'], 'custom-title-nonce')) return $post_id;
	if (defined('DOING_AUTOSAVE') &amp;&amp; DOING_AUTOSAVE) return $post_id;
	$customTitle = $_POST['custom_title_input'];
	update_post_meta($post_id, '_custom_title', $customTitle);
}
function insert_custom_title() {
	if (have_posts()) : the_post();
	  $customTitle = get_post_meta(get_the_ID(), '_custom_title', true);
	  if ($customTitle) {
		echo "&lt;title&gt;$customTitle&lt;/title&gt;";
      } else {
    	echo "&lt;title&gt;";
	      if (is_tag()) {
	         single_tag_title("Tag Archive for &amp;quot;"); echo '&amp;quot; - '; }
	      elseif (is_archive()) {
	         wp_title(''); echo ' Archive - '; }
	      elseif ((is_single()) || (is_page()) &amp;&amp; (!(is_front_page())) ) {
	         wp_title(''); echo ' - '; }
	      if (is_home()) {
	         bloginfo('name'); echo ' - '; bloginfo('description'); }
	      else {
	          bloginfo('name'); }
	      if ($paged&gt;1) {
	         echo ' - page '. $paged; }
        echo "&lt;/title&gt;";
    }
    else :
      echo "&lt;title&gt;Page Not Found | Envision&lt;/title&gt;";
	endif;
	rewind_posts();
}</code></pre>
<p>The new input box we are putting on the page saves its value as a custom field on the Post/Page you are on. The key of that custom field is &#8220;_custom_title&#8221;, so it doesn&#8217;t show in the regular custom field list (custom fields that start with underscores don&#8217;t).</p>
<p>Now when any front-end page of the site loads, it checks that page to see if that custom field exists. If it does exist, it uses that value exactly for the page title. If it doesn&#8217;t, it defaults to a generically smart page title structure.</p>
<h3>Result</h3>
<p>This is the box that now is available when creating or editing a Page/Post:</p>
<p><img src="http://digwp.com/wp-content/blog-images/custompagetitle.png" width="590" height="194" alt="" title="" /></p>
<p>And that is what will be used:</p>
<p><img src="http://digwp.com/wp-content/blog-images/customtitleexerted.jpg" width="520" height="200" alt="" title="" /></p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/04/custom-page-titles/">Permalink</a> | <a href="http://digwp.com/2010/04/custom-page-titles/#comments">21 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/04/custom-page-titles/&title=Custom Page Titles from Scratch">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/title/" rel="tag">title</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/04/custom-page-titles/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Call a Widget with a Shortcode</title>
		<link>http://digwp.com/2010/04/call-widget-with-shortcode/</link>
		<comments>http://digwp.com/2010/04/call-widget-with-shortcode/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 17:30:03 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[widgets]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1752</guid>
		<description><![CDATA[We covered how to run a shortcode in a widget. But what about inserting a widget with a shortcode? I recently had this situation come up. I had a single page where I just wanted to be able to chuck in a widget without the whole rigmarole of creating a special widgetized area and probably [...]]]></description>
			<content:encoded><![CDATA[<p>We covered how to <a href="http://digwp.com/2010/03/shortcodes-in-widgets/">run a shortcode in a widget</a>. But what about inserting a widget with a shortcode? I recently had this situation come up. I had a single page where I just wanted to be able to chuck in a widget without the whole rigmarole of creating a special widgetized area and probably a custom page template for that widgetized area and such. I wanted to just put [widget widget_name="my_widget"] in the pages content and have that widget pop in. Turns out it wasn&#8217;t as easy I wanted it to be, but it&#8217;s not that bad&#8230;</p>
<p><span id="more-1752"></span></p>
<p>The answer was creating a custom function for the functions.php file which would output any widget by name. There is a function just for that: <code>the_widget()</code> (<a href="http://codex.wordpress.org/Template_Tags/the_widget">incomplete codex page</a>).</p>
<h3>The logic</h3>
<ol>
<li>Test if widget exists</li>
<li>If it does&#8230;
<ol>
<li>Start capturing output</li>
<li>Output widget</li>
<li>End capturing output</li>
<li>Return captured output</li>
</ol>
</li>
<li>If it doesn&#8217;t exist&#8230;
<ol>
<li>Output fail message</li>
</ol>
</li>
</ol>
<h3>The code for functions.php</h3>
<pre><code>function widget($atts) {
    
    global $wp_widget_factory;
    
    extract(shortcode_atts(array(
        'widget_name' =&gt; FALSE
    ), $atts));
    
    $widget_name = wp_specialchars($widget_name);
    
    if (!is_a($wp_widget_factory-&gt;widgets[$widget_name], 'WP_Widget')):
        $wp_class = 'WP_Widget_'.ucwords(strtolower($class));
        
        if (!is_a($wp_widget_factory-&gt;widgets[$wp_class], 'WP_Widget')):
            return '&lt;p&gt;'.sprintf(__("%s: Widget class not found. Make sure this widget exists and the class name is correct"),'&lt;strong&gt;'.$class.'&lt;/strong&gt;').'&lt;/p&gt;';
        else:
            $class = $wp_class;
        endif;
    endif;
    
    ob_start();
    the_widget($widget_name, $instance, array('widget_id'=&gt;'arbitrary-instance-'.$id,
        'before_widget' =&gt; '',
        'after_widget' =&gt; '',
        'before_title' =&gt; '',
        'after_title' =&gt; ''
    ));
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
    
}
add_shortcode('widget','widget'); </code></pre>
<h3>Usage</h3>
<p>Now in Post/Page content, you can use the widget just by referencing it by name:</p>
<pre><code>[widget widget_name="Your_Custom_Widget"]</code></pre>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/04/call-widget-with-shortcode/">Permalink</a> | <a href="http://digwp.com/2010/04/call-widget-with-shortcode/#comments">15 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/04/call-widget-with-shortcode/&title=Call a Widget with a Shortcode">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/theme/" rel="tag">Theme</a>, <a href="http://digwp.com/tag/widgets/" rel="tag">widgets</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/04/call-widget-with-shortcode/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>WordPress Custom functions.php Template, Part 2</title>
		<link>http://digwp.com/2010/04/wordpress-custom-functions-php-template-part-2/</link>
		<comments>http://digwp.com/2010/04/wordpress-custom-functions-php-template-part-2/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 16:13:36 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1811</guid>
		<description><![CDATA[In a recent post, we show you how to clean up and enhance the functionality of WordPress with a custom functions.php template. In that post, we explain how using a custom functions.php template can speed up development while optimizing many key aspects of WordPress. In this post, we deliver another prime collection of 15 custom [...]]]></description>
			<content:encoded><![CDATA[<p>In a recent post, we show you how to clean up and enhance the functionality of WordPress with a <a href="http://digwp.com/2010/03/wordpress-functions-php-template-custom-functions/" title="WordPress functions.php Template with 15 Essential Custom Functions">custom functions.php template</a>. In <em>that</em> post, we explain how using a custom <code>functions.php</code> template can speed up development while optimizing many key aspects of WordPress. In <em>this</em> post, we deliver another prime collection of <strong>15 custom functions to enhance your WordPress site</strong>. These functions provide all sorts of useful functionality, including stuff like:</p>
<ul>
<li>Callback function for a custom comments loop</li>
<li>Automatic content insertion in posts and feeds</li>
<li>Spam and delete links for comments when logged in</li>
<li>Buffer period before new posts are added to your feeds</li>
<li>Including an Admin link to the &ldquo;All-Settings&rdquo; page</li>
<li>Removing the version and generator information from your site and feed</li>
</ul>
<p>These new functions <em>extend</em> the functionality of our original <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 template</a> with <strong>15 more useful functions</strong>. Not everything presented here is going to be necessary for <em>all</em> of your themes, so just grab what you need and add it your own custom <code>functions.php</code> file.</p>
<p><span id="more-1811"></span></p>
<blockquote><p>In this <acronym title="Digging into WordPress">DiW</acronym> article, we extend our original functions.php template with 15 more useful functions.</p></blockquote>
<p>As before, we&rsquo;ll first walk through each of the functions and then unify them into a working <code>functions.php</code> template. To use, just copy and paste the template code at the end of this article or <a href="#functions-download" title="Download the zipped template file">grab a copy of the zipped functions.php file</a> and enjoy a custom collection of functions that will help you <strong>optimize your development process</strong> while enhancing WordPress with some <strong>awesome new functionality</strong>.</p>
<h3>Insert custom content after each post</h3>
<p>If you look at the different things contained within a typical post, you will find many common and repetitive items, such as feed links, copyright information, and <a href="http://perishablepress.com/press/2008/11/23/fully-valid-seo-friendly-social-media-links-for-wordpress/" title="Fully Valid, SEO-Friendly Social Media Links for WordPress">social-media bookmarks</a>. While there&rsquo;s nothing wrong with inserting this content into your <code>single.php</code> template, it is sometimes easier to manage things from the <code>functions.php</code> file. For example, at <a href="http://perishablepress.com/" title="Digital Design and Dialogue">Perishable Press</a>, I include a brief copyright statement at the end of each post. By including the following code in my <code>functions.php</code> template, it&rsquo;s something that happens automatically:</p>
<pre><code>// add custom post content
function add_post_content($content) {
	if(!is_feed() &amp;&amp; !is_home()) {
		$content .= '&lt;p&gt;This article is copyright &amp;copy; '.date('Y').'&amp;nbsp;'.bloginfo('name').'&lt;/p&gt;';
	}
	return $content;
}
add_filter('the_content', 'add_post_content');</code></pre>
<p>The trick here is an old one, but it&rsquo;s extremely useful. By changing the line beginning with &ldquo;<code>$content.</code>&rdquo;, you can add just about any content you like.</p>
<h3>Insert custom content in your feeds</h3>
<p>Just as with the previous method, this function makes it possible to automatically add any content to your feeds. Yes, I know there are plugins that will <a href="http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/" title="Wordpress Plugin : Better Feed">make your feed footers do backflips</a>, but for a simple copyright message or other info, I think it is easier and more efficient to simply toss a few lines into your custom <code>functions.php</code> template:</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>As before, you can change the added content to whatever you want by editing the &ldquo;<code>$content</code>&rdquo; variable. Once in place, this will append a dynamic copyright message to each post in your feed. Note: if you happen to be adding the same content to your web pages (using the previous method) <em>and</em> your feeds (using this method), you may combine the two functions like so:</p>
<pre><code>// add custom content to feeds and posts
function add_custom_content($content) {
	if(!is_home()) {
		$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_custom_content');
add_filter('the_content', 'add_custom_content');</code></pre>
<p>Remember that if you use this combined function that you should remove or comment out both of the individual ones to avoid duplicate output. It will be included but commented out in the complete <code>functions.php</code> template file.</p>
<h3>Completely remove the version number from pages and feeds</h3>
<p>A commonly cited <a href="http://digwp.com/2009/07/remove-wordpress-version-number/" title="How to Remove the WordPress Version Number (The Right Way)">security measure for WordPress-powered sites</a> involves removing the automatically generated version number from appearing in the <code>&lt;head&gt;</code> section of your pages&rsquo; source code. This type of security technique is referred to as &ldquo;security through obscurity,&rdquo; and aims at hiding potentially sensitive information from a would-be attacker. Here&rsquo;s a function that does the job:</p>
<pre><code>// remove version info from head and feeds
function complete_version_removal() {
	return '';
}
add_filter('the_generator', 'complete_version_removal');</code></pre>
<p>This will remove your site&rsquo;s version and generator information from all of your pages and feeds, making it a little bit harder for the bad guys and a little bit safer for you and your visitors.</p>
<h3>Customize the admin footer message</h3>
<p>Customization is what makes your online experience something special. For your own sites and for your clients&rsquo; sites, it is nice to customize the generic admin footer message with something a little more useful, informative, and inspiring. This little gem makes it easy:</p>
<pre><code>// customize admin footer text
function custom_admin_footer() {
	echo '&lt;a href="http://monzilla.biz/"&gt;Website Design by Monzilla Media&lt;/a&gt;';
} 
add_filter('admin_footer_text', 'custom_admin_footer');</code></pre>
<p>Here, for the sake of example, we are including a link to my web-design company, but you can customize the content with just about anything you wish. If this were something I had to do manually for each site, I probably wouldn&rsquo;t do it. But by adding these few lines to my <code>functions.php</code> template, it all happens automatically, without me having to think about it. Nice&nbsp;;)</p>
<h3>Enable HTML markup in user profiles</h3>
<p>When customizing their profiles, users may want to include a hyperlink, bold text, or some other <acronym title="Hypertext markup language">HTML</acronym> markup. By default, WordPress prevents this from happening, but you can easily enable it with this friendly little snippet:</p>
<pre><code>// enable html markup in user profiles
remove_filter('pre_user_description', 'wp_filter_kses');</code></pre>
<p><strong>Note:</strong> as <a href="#comment-4171" title="Jump to comment">miqrogroove</a> points out, enabling <acronym title="Hypertext markup language">HTML</acronym> may be best left to sites that have open user-registration disabled. Use with discretion.</p>
<h3>Delay feed update after posting</h3>
<p>As a chronic perfectionist, I hate it when I post something only to discover an error a few minutes later. By the time I notice, fix and update the post, it&rsquo;s already been beamed out all over the freakin&rsquo; place. To prevent this, I like to take the advice of <a href="http://wpengineer.com/publish-the-feed-later/" title="Publish The Feed Later">WPEngineer</a> and give myself a little buffer period or &ldquo;safety net&rdquo; after publishing my posts.</p>
<pre><code>// delay feed update
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;
}
add_filter('posts_where', 'publish_later_on_feed');</code></pre>
<p>This code quietly and automatically gives me an extra five minutes before my post is added to my feeds. If you need more or less than five minutes, just edit the &ldquo;<code>$wait</code>&rdquo; variable with the integer of your choice.</p>
<h3>Add an Admin link to the WordPress &ldquo;All-Settings&rdquo; page</h3>
<p>As we&rsquo;ve explained before, WordPress makes it easy to <a href="http://digwp.com/2009/06/edit-your-database-options-from-the-wordpress-admin/" title="Edit Your Database Options from the WordPress Admin">view and edit your blog settings from the Admin area</a>. Thanks to a file named &ldquo;<code>options.php</code>&rdquo;, WordPress will display all of your database settings and enable you to edit a majority of them. To view this page, you need to log in as Admin and enter this <acronym title="Uniform Resource Locator">URL</acronym> in your browser&rsquo;s address bar:</p>
<p><code>http://domain.tld/wp-admin/options.php</code></p>
<p>Having access to your &ldquo;All-Settings&rdquo; page can be extremely helpful, so it&rsquo;s nice to display a direct link for easy access. The following slice of code in your <code>functions.php</code> file is all that&rsquo;s needed:</p>
<pre><code>// admin link for all settings
function all_settings_link() {
	add_options_page(__('All Settings'), __('All Settings'), 'administrator', 'options.php');
}
add_action('admin_menu', 'all_settings_link');</code></pre>
<p>Once in place, you will see a link to your &ldquo;All Settings&rdquo; page in the WordPress Admin. You can change the name of the link to whatever you prefer by editing the two instances of &ldquo;All Settings&rdquo;.</p>
<h3>Remove all nofollow attributes from comments</h3>
<p>There are <a href="http://perishablepress.com/press/2007/09/23/much-ado-about-nofollow-the-perishable-press-dofollow-series/" title="Much ado about nofollow: The Perishable Press Dofollow Series">a million ways</a> to <a href="http://perishablepress.com/press/2007/09/05/comprehensive-reference-for-wordpress-no-nofollow-dofollow-plugins/" title="Comprehensive Reference for WordPress NoNofollow/Dofollow Plugins">remove nofollow</a> from your comments, but nothing is as <em>easy</em> as this method provided by code guru <a href="http://toscho.de/2009/no-no-no-nofollow/" title="No no no nofollow">Thomas Scholz</a>:</p>
<pre><code>// remove nofollow from comments
function xwp_dofollow($str) {
	$str = preg_replace(
		'~&lt;a ([^&gt;]*)\s*(["|\']{1}\w*)\s*nofollow([^&gt;]*)&gt;~U',
		'&lt;a ${1}${2}${3}&gt;', $str);
	return str_replace(array(' rel=""', " rel=''"), '', $str);
}
remove_filter('pre_comment_content',     'wp_rel_nofollow');
add_filter   ('get_comment_author_link', 'xwp_dofollow');
add_filter   ('post_comments_link',      'xwp_dofollow');
add_filter   ('comment_reply_link',      'xwp_dofollow');
add_filter   ('comment_text',            'xwp_dofollow');</code></pre>
<p>That code will remove all instances of the nefarious &ldquo;<code>nofollow</code>&rdquo; attribute from <em>all</em> comment items, including the author link and comment text. This is a great way to automatically remove nofollow with no plugins or hacking required.</p>
<h3>Enable easy display of your post&rsquo;s word count</h3>
<p>This function enables you to display your post&rsquo;s word count without cluttering up the WordPress loop. To display the word count of your posts, first place this in your <code>functions.php</code> file:</p>
<pre><code>// count words in posts
function word_count() {
	global $post;
	echo str_word_count($post-&gt;post_content);
}</code></pre>
<p>Then, simply place this anywhere in your loop where you would like the number to appear:</p>
<p><code>&lt;?php word_count(); ?&gt;</code></p>
<p>So for example, you could display your post&rsquo;s word count to your visitors with something like:</p>
<p><code>&lt;p&gt;This post contains a whopping &lt;?php word_count(); ?&gt; words.&lt;/p&gt;</code></p>
<p>We can also easily display the word count of other items, such as the post title:</p>
<p><code>&lt;?php echo str_word_count($post-&gt;post_title); ?&gt;</code></p>
<p>Likewise, we can exclude the function from <code>functions.php</code> and get the word count with a single line of code in the loop:</p>
<p><code>&lt;?php echo str_word_count($post-&gt;post_content); ?&gt;</code></p>
<p>Just slap &lsquo;em anywhere in your post loop to display your word count. Not always needed, but nice to have available&nbsp;;)</p>
<h3>Enable delete and spam links for comments</h3>
<p>Managing your comments is easily done via the Admin, but geeks like me also like to see things from the outside, as they appear to the public. Browsing through comments as they appear on your site helps you catch things that may have eluded routine approvals in the Admin&rsquo;s comment listings. To help facilitate this process, I like to include a <a href="http://perishablepress.com/press/2008/12/01/spam-delete-buttons-links-for-old-versions-wordpress/" title="Backwards-Compatible Spam and Delete Buttons for WordPress">backwards-compatible set of spam and delete links</a> next to each comment. This makes it super-easy to cultivate comments live on the site.</p>
<pre><code>// spam &amp; delete links for all versions of wordpress
function delete_comment_link($id) {
	if (current_user_can('edit_post')) {
		echo '| &lt;a href="'.get_bloginfo('wpurl').'/wp-admin/comment.php?action=cdc&amp;c='.$id.'"&gt;del&lt;/a&gt; ';
		echo '| &lt;a href="'.get_bloginfo('wpurl').'/wp-admin/comment.php?action=cdc&amp;dt=spam&amp;c='.$id.'"&gt;spam&lt;/a&gt;';
	}
}</code></pre>
<p>Once this is included in your <code>functions.php</code> file, displaying the links is as easy as adding this to your comments loop:</p>
<pre><code>&lt;?php delete_comment_link(get_comment_ID()); ?&gt;</code></pre>
<h3>Disable all WordPress feeds</h3>
<p>Thanks to <a href="http://wpengineer.com/disable-wordpress-feed/" title="How to Disable RSS Feeds in WordPress">Frank from WPEngineer</a>, it is easy to disable all feed functionality for your site. Here is the <code>functions.php</code> code:</p>
<p><strong>Note:</strong> Only use this function if you want to <em>disable</em> your feeds! This function will be commented out of the complete <code>functions.php</code> file.</p>
<pre><code>// disable all feeds
function fb_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',      'fb_disable_feed', 1);
add_action('do_feed_rdf',  'fb_disable_feed', 1);
add_action('do_feed_rss',  'fb_disable_feed', 1);
add_action('do_feed_rss2', 'fb_disable_feed', 1);
add_action('do_feed_atom', 'fb_disable_feed', 1);</code></pre>
<p>This function will quietly and completely disable all of your site&rsquo;s feeds, including all different formats. With this code in place, any request for your feed will return the following message in a nice, big set of <code>&lt;h1&gt;</code> tags:</p>
<blockquote><p>Feed not available, please visit our <a href="http://digwp.com/">Home Page</a>!</p></blockquote>
<p>This message is easily customized by editing the &ldquo;<code>wp_die</code>&rdquo; argument in the function.</p>
<h3>Customize the default gravatars and add your own</h3>
<p>Instead of suffering with the rather dull default gravatars, use this code to customize your own: </p>
<pre><code>// customize default gravatars
function custom_gravatars($avatar_defaults) {

	// change the default gravatar
	$customGravatar1 = get_bloginfo('template_directory').'/images/gravatar-01.png';
	$avatar_defaults[$customGravatar1] = 'Default';

	// add a custom user gravatar
	$customGravatar2 = get_bloginfo('template_directory').'/images/gravatar-02.png';
	$avatar_defaults[$customGravatar2] = 'Custom Gravatar';

	// add another custom gravatar
	$customGravatar3 = get_bloginfo('template_directory').'/images/gravatar-03.png';
	$avatar_defaults[$customGravatar3] = 'Custom gravatar';

	return $avatar_defaults;
}
add_filter('avatar_defaults', 'custom_gravatars');</code></pre>
<p>Of course, you can manually choose a default gravatar by specifying its location via the &ldquo;<code>get_avatar</code>&rdquo; template tag, but this method makes it <em>so</em> much easier. Not only does it replace the default with <em>multiple</em> custom gravatars, but it also goes the extra mile by displaying them in the WordPress Admin area under <strong>Settings &gt; Discussion</strong>. From there, you can select any of your custom gravatars by simply selecting it and clicking the &ldquo;Update&rdquo; button. Nothing could be easier. </p>
<p>A few notes about this function:</p>
<ul>
<li>As is, it adds three new gravatars to choose as defaults.</li>
<li>Each gravatar should be located in your theme&rsquo;s <code>images</code> directory.</li>
<li>You can add as many default gravatars as you would like by emulating the code pattern.</li>
<li>If you keep your custom gravatars someplace else, be sure and edit the image paths accordingly.</li>
</ul>
<h3>Disable automatic formatting in post content via shortcode</h3>
<p><a href="http://www.wprecipes.com/disable-wordpress-automatic-formatting-on-posts-using-a-shortcode" title="Disable WordPress automatic formatting on posts using a shortcode">WPRecipes</a> shows us how to prevent WordPress from automatically formatting chunks of post content by using a shortcode. This is very useful for posting code, poetry, or anything else that you would like to display in raw format. To do this, we add the following snippet to our <code>functions.php</code> file:</p>
<pre><code>// disable auto formatting in posts
function my_formatter($content) {
	$new_content = '';
	$pattern_full = '{(\[raw\].*?\[/raw\])}is';
	$pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
	$pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);

	foreach ($pieces as $piece) {
		if (preg_match($pattern_contents, $piece, $matches)) {
			$new_content .= $matches[1];
		} else {
			$new_content .= wptexturize(wpautop($piece));
		}
	}

	return $new_content;
}
remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');
add_filter('the_content', 'my_formatter', 99);</code></pre>
<p>With that code in place, you can insert unformatted code into your posts via the &ldquo;<code>[raw]</code>&rdquo; shortcode, for example:</p>
<p><code>[raw]Unformatted content[/raw]</code></p>
<p>Anything contained within those shortcodes will be left unformatted when displayed in your posts.</p>
<h3>Escape HTML entities in comments</h3>
<p><a href="http://konstruktors.com/blog/wordpress/1850-automatically-escape-html-entities-of-code-fragments-in-comments/" title="Automatically Escape HTML Entities of Code Fragments in Comments">Kaspars Dambis</a> shows us how to automatically escape encoded <acronym title="Hypertext markup Language">HTML</acronym> entities in the comments that readers leave on your posts. This is especially useful for blogs that deal in heavy code exchanges on post threads. This enables your commentators to simply wrap their code in <code>&lt;code&gt;</code> tags and not have to worry about manually converting characters such as angled brackets (&ldquo;<code>&lt;</code>&rdquo; &amp; &ldquo;<code>&gt;</code>&rdquo;) into their encoded equivalents (&ldquo;<code>&amp;lt;</code>&rdquo; &amp; &ldquo;<code>&amp;gt;</code>&rdquo;).</p>
<pre><code>// escape html entities in comments
function encode_code_in_comment($source) {
	$encoded = preg_replace_callback('/&lt;code&gt;(.*?)&lt;\/code&gt;/ims',
	create_function('$matches', '$matches[1] = preg_replace(array("/^[\r|\n]+/i", "/[\r|\n]+$/i"), "", $matches[1]); 
	return "&lt;code&gt;" . htmlentities($matches[1]) . "&lt;/"."code&gt;";'), $source);
	if ($encoded)
		return $encoded;
	else
		return $source;
}
add_filter('pre_comment_content', 'encode_code_in_comment');</code></pre>
<p>Once in place in your <code>functions.php</code> file, simply tell your commentators to wrap their code snippets in <code>&lt;code&gt;</code> tags. In other words, any content wrapped in <code>&lt;code&gt;</code> tags will be encoded automatically. Plus, in order to prevent unwanted <code>&lt;br</code>&nbsp;<code>/&gt;</code> tags, this function also automatically removes line breaks after the opening <code>&lt;code&gt;</code> tag and before the closing <code>&lt;code&gt;</code> tag.</p>
<h3>Custom comments display callback function</h3>
<p>When designing your theme&rsquo;s <code>comments.php</code> file, you can use either WordPress&rsquo; default code or create your own for full control over your comments display. If you&rsquo;re rolling your own, it is often easiest to grab a solid comments-display template and customize it to suit your needs. After many iterations and much refining, here is the comments callback function that I usually begin with:</p>
<pre><code>// custom comments callback function
function custom_comments_callback($comment, $args, $depth) {
	$GLOBALS['comment'] = $comment; ?&gt;

	&lt;li &lt;?php comment_class(); ?&gt; id="comment-&lt;?php comment_ID(); ?&gt;"&gt;
		&lt;div class="comment-wrap"&gt;
			&lt;?php echo get_avatar(get_comment_author_email(), $size = '50', $default = bloginfo('stylesheet_directory').'/images/gravatar.png'); ?&gt;

			&lt;div class="comment-intro"&gt;
            			&lt;?php printf(__('%s'), get_comment_author_link()); ?&gt; &amp;ndash; &lt;a class="comment-permalink" href="&lt;?php echo htmlspecialchars(get_comment_link($comment-&gt;comment_ID)); ?&gt;"&gt;&lt;?php comment_date('F j, Y'); ?&gt; @ &lt;?php comment_time(); ?&gt;&lt;/a&gt;&lt;?php edit_comment_link('Edit', ' &amp;ndash; ', ''); ?&gt;
			&lt;/div&gt;
			&lt;?php if ($comment-&gt;comment_approved == '0') : ?&gt;

			&lt;p class="comment-moderation"&gt;&lt;?php _e('Your comment is awaiting moderation.'); ?&gt;&lt;/p&gt;
			&lt;?php endif; ?&gt;

			&lt;div class="comment-text"&gt;&lt;?php comment_text(); ?&gt;&lt;/div&gt;

			&lt;div class="reply" id="comment-reply-&lt;?php comment_ID(); ?&gt;"&gt;
				&lt;?php comment_reply_link(array_merge($args, array('reply_text'=&gt;'Reply', 'login_text'=&gt;'Log in to Reply', 'add_below'=&gt;'comment-reply', 'depth'=&gt;$depth, 'max_depth'=&gt;$args['max_depth']))); ?&gt; 

			&lt;/div&gt;
		&lt;/div&gt;

&lt;?php } // WP adds the closing &lt;/li&gt;</code></pre>
<p>There&rsquo;s a lot going on here, so let&rsquo;s highlight the important stuff:</p>
<ul>
<li><strong>Do not</strong> add the closing <code>&lt;/li&gt;</code> element &ndash; <a href="http://digwp.com/2010/02/custom-comments-html-output/" title="Custom Comments HTML Output">WordPress does this for you</a>.</li>
<li>This function calls for a default gravatar in your theme&rsquo;s &ldquo;<code>images</code>&rdquo; directory. Either ensure you&rsquo;ve got the required image in place or edit the code to reflect your site&rsquo;s reality.</li>
<li>Once this function is included in your <code>functions.php</code> file, you can display it by using the following comments loop in your <code>comments.php</code> file:</li>
</ul>
<pre><code>&lt;?php if (have_comments()) : ?&gt;
&lt;ol class="commentlist"&gt;
	&lt;?php wp_list_comments('type=comment&amp;style=ol&amp;callback=custom_comments_callback'); ?&gt;
&lt;/ol&gt;
&lt;?php else : ?&gt;</code></pre>
<p>Notice the third parameter for the <code>wp_list_comments</code> template tag? that&rsquo;s what makes it go. Also important is the &ldquo;<code>style=ol</code>&rdquo; parameter, which tells WordPress that we are using an ordered list for comments and that it should automatically close the markup with a <code>&lt;/li&gt;</code> element.</p>
<h3>Putting it all together..</h3>
<p>As promised, here is the full-meal deal &ndash; the entire collection neatly organized into a single chunk of code:</p>
<pre><code>&lt;?php // custom functions.php template @ digwp.com

// add custom post content
function add_post_content($content) {
	if(!is_feed() &amp;&amp; !is_home()) {
		$content .= '&lt;p&gt;This article is copyright &amp;copy; '.date('Y').'&amp;nbsp;'.bloginfo('name').'&lt;/p&gt;';
	}
	return $content;
}
add_filter('the_content', 'add_post_content');


// 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');


/* add custom content to feeds and posts
function add_custom_content($content) {
	if(!is_home()) {
		$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_custom_content');
add_filter('the_content', 'add_custom_content'); */


// remove version info from head and feeds
function complete_version_removal() {
	return '';
}
add_filter('the_generator', 'complete_version_removal');


// customize admin footer text
function custom_admin_footer() {
	echo '&lt;a href="http://monzilla.biz/"&gt;Website Design by Monzilla Media&lt;/a&gt;';
} 
add_filter('admin_footer_text', 'custom_admin_footer');


// enable html markup in user profiles
remove_filter('pre_user_description', 'wp_filter_kses');


// delay feed update
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;
}
add_filter('posts_where', 'publish_later_on_feed');


// admin link for all settings
function all_settings_link() {
	add_options_page(__('All Settings'), __('All Settings'), 'administrator', 'options.php');
}
add_action('admin_menu', 'all_settings_link');


// remove nofollow from comments
function xwp_dofollow($str) {
	$str = preg_replace(
		'~&lt;a ([^&gt;]*)\s*(["|\']{1}\w*)\s*nofollow([^&gt;]*)&gt;~U',
		'&lt;a ${1}${2}${3}&gt;', $str);
	return str_replace(array(' rel=""', " rel=''"), '', $str);
}
remove_filter('pre_comment_content',     'wp_rel_nofollow');
add_filter   ('get_comment_author_link', 'xwp_dofollow');
add_filter   ('post_comments_link',      'xwp_dofollow');
add_filter   ('comment_reply_link',      'xwp_dofollow');
add_filter   ('comment_text',            'xwp_dofollow');


// count words in posts
function word_count() {
	global $post;
	echo str_word_count($post-&gt;post_content);
}


// spam &amp; delete links for all versions of wordpress
function delete_comment_link($id) {
	if (current_user_can('edit_post')) {
		echo '| &lt;a href="'.get_bloginfo('wpurl').'/wp-admin/comment.php?action=cdc&amp;c='.$id.'"&gt;del&lt;/a&gt; ';
		echo '| &lt;a href="'.get_bloginfo('wpurl').'/wp-admin/comment.php?action=cdc&amp;dt=spam&amp;c='.$id.'"&gt;spam&lt;/a&gt;';
	}
}


/* disable all feeds
function fb_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',      'fb_disable_feed', 1);
add_action('do_feed_rdf',  'fb_disable_feed', 1);
add_action('do_feed_rss',  'fb_disable_feed', 1);
add_action('do_feed_rss2', 'fb_disable_feed', 1);
add_action('do_feed_atom', 'fb_disable_feed', 1); */


// customize default gravatars
function custom_gravatars($avatar_defaults) {

	// change the default gravatar
	$customGravatar1 = get_bloginfo('template_directory').'/images/gravatar-01.png';
	$avatar_defaults[$customGravatar1] = 'Default';

	// add a custom user gravatar
	$customGravatar2 = get_bloginfo('template_directory').'/images/gravatar-02.png';
	$avatar_defaults[$customGravatar2] = 'Custom Gravatar';

	// add another custom gravatar
	$customGravatar3 = get_bloginfo('template_directory').'/images/gravatar-03.png';
	$avatar_defaults[$customGravatar3] = 'Custom gravatar';

	return $avatar_defaults;
}
add_filter('avatar_defaults', 'custom_gravatars');


// disable auto formatting in posts
function my_formatter($content) {
	$new_content = '';
	$pattern_full = '{(\[raw\].*?\[/raw\])}is';
	$pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
	$pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);

	foreach ($pieces as $piece) {
		if (preg_match($pattern_contents, $piece, $matches)) {
			$new_content .= $matches[1];
		} else {
			$new_content .= wptexturize(wpautop($piece));
		}
	}

	return $new_content;
}
remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');
add_filter('the_content', 'my_formatter', 99);


// escape html entities in comments
function encode_code_in_comment($source) {
	$encoded = preg_replace_callback('/&lt;code&gt;(.*?)&lt;\/code&gt;/ims',
	create_function('$matches', '$matches[1] = preg_replace(array("/^[\r|\n]+/i", "/[\r|\n]+$/i"), "", $matches[1]); 
	return "&lt;code&gt;" . htmlentities($matches[1]) . "&lt;/"."code&gt;";'), $source);
	if ($encoded)
		return $encoded;
	else
		return $source;
}
add_filter('pre_comment_content', 'encode_code_in_comment');


// custom comments callback function
function custom_comments_callback($comment, $args, $depth) {
	$GLOBALS['comment'] = $comment; ?&gt;

	&lt;li &lt;?php comment_class(); ?&gt; id="comment-&lt;?php comment_ID(); ?&gt;"&gt;
		&lt;div class="comment-wrap"&gt;
			&lt;?php echo get_avatar(get_comment_author_email(), $size = '50', $default = bloginfo('stylesheet_directory').'/images/gravatar.png'); ?&gt;

			&lt;div class="comment-intro"&gt;
            			&lt;?php printf(__('%s'), get_comment_author_link()); ?&gt; &amp;ndash; &lt;a class="comment-permalink" href="&lt;?php echo htmlspecialchars(get_comment_link($comment-&gt;comment_ID)); ?&gt;"&gt;&lt;?php comment_date('F j, Y'); ?&gt; @ &lt;?php comment_time(); ?&gt;&lt;/a&gt;&lt;?php edit_comment_link('Edit', ' &amp;ndash; ', ''); ?&gt;
			&lt;/div&gt;
			&lt;?php if ($comment-&gt;comment_approved == '0') : ?&gt;

			&lt;p class="comment-moderation"&gt;&lt;?php _e('Your comment is awaiting moderation.'); ?&gt;&lt;/p&gt;
			&lt;?php endif; ?&gt;

			&lt;div class="comment-text"&gt;&lt;?php comment_text(); ?&gt;&lt;/div&gt;

			&lt;div class="reply" id="comment-reply-&lt;?php comment_ID(); ?&gt;"&gt;
				&lt;?php comment_reply_link(array_merge($args, array('reply_text'=&gt;'Reply', 'login_text'=&gt;'Log in to Reply', 'add_below'=&gt;'comment-reply', 'depth'=&gt;$depth, 'max_depth'=&gt;$args['max_depth']))); ?&gt; 

			&lt;/div&gt;
		&lt;/div&gt;

&lt;?php } // WP adds the closing &lt;/li&gt;

?&gt;</code></pre>
<h3 id="functions-download">Download the custom functions.php template file</h3>
<p>If you prefer, you can download this code in a ready-to-go <code>functions.php</code> file in zipped format:</p>
<h4><a href="http://digwp.com/plugins/custom-functions-template-2.zip">Download zipped functions.php Template File</a></h4>
<h3>Also..</h3>
<p>If this post is useful to <acronym title="Digging into WordPress">DiW</acronym> readers, I’ll be writing up yet another article (part 3!) with even more useful custom functions. If that happens, the third set of functions will include some slightly more advanced techniques. <a href="http://feeds2.feedburner.com/DiggingIntoWordpress" title="Grab the Feed!">Stay tuned</a>!</p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/04/wordpress-custom-functions-php-template-part-2/">Permalink</a> | <a href="http://digwp.com/2010/04/wordpress-custom-functions-php-template-part-2/#comments">17 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/04/wordpress-custom-functions-php-template-part-2/&title=WordPress Custom functions.php Template, Part 2">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/template/" rel="tag">template</a>, <a href="http://digwp.com/tag/theme/" rel="tag">Theme</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/04/wordpress-custom-functions-php-template-part-2/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>WordPress functions.php Template with 15 Essential Custom Functions</title>
		<link>http://digwp.com/2010/03/wordpress-functions-php-template-custom-functions/</link>
		<comments>http://digwp.com/2010/03/wordpress-functions-php-template-custom-functions/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 06:25:58 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1699</guid>
		<description><![CDATA[When designing WordPress themes, I always add a common set of custom functions to the theme&#8217;s functions.php file. This speeds up development time because I don&#8217;t have to hunt for and individually copy the same slew of functions for every theme. I just drop in a copy of my functions.php template and build up from [...]]]></description>
			<content:encoded><![CDATA[<p>When designing WordPress themes, I always add <strong>a common set of custom functions</strong> to the theme&rsquo;s <code>functions.php</code> file. This speeds up development time because I don&rsquo;t have to hunt for and individually copy the same slew of functions for <em>every</em> theme. I just drop in a copy of my <strong>functions.php template</strong> and build up from there. This takes care of all those little things that always need to be done:</p>
<ul>
<li>Include jQuery</li>
<li>Enable threaded comments</li>
<li>Add feed links to the header</li>
<li>Disable unused widget areas</li>
<li>Adding Google Analytics to the footer</li>
<li>Stop the &ldquo;Read More&rdquo; link from jumping to the middle of the next page&nbsp;;)</li>
</ul>
<p>One of the things that I like about these functions is that they&rsquo;re all so concise, simple, and effective. The <code>functions.php</code> template file currently contains 15 different functions and is a continual work in progress. Not everyone is going to need or use everything in the file, but the idea is to modify this template into something that works for you. It&rsquo;s a starting point with some really useful functions.</p>
<p><span id="more-1699"></span></p>
<p>In this <acronym title="Digging into WordPress">DiW</acronym> article, we first provide an explanation of each of the 15 functions and then bring them all together into the working <code>functions.php</code> template. Just copy and paste the template code at the end of this article or <a href="#functions-download" title="Download the zipped template file">grab a copy of the zipped <code>functions.php</code> file</a> and enjoy a custom collection of functions that will help you optimize your development process while enhancing WordPress with essential functionality.</p>
<h3>Add feed links to header</h3>
<p>Since version 2.8, WordPress can add all relevant feed links (main, comments, categories, et al) to your <code>&lt;head&gt;</code> area. It doesn&rsquo;t happen by default, however, because you have to add the following snippet to make it work:</p>
<pre><code>// add feed links to header
if (function_exists('automatic_feed_links')) {
	automatic_feed_links();
} else {
	return;
}</code></pre>
<p>This will check to see if you&rsquo;re using a version of WordPress that is compatible, and then enable the automatic feed links. A couple of notes: first, this method assumes that you are not manually including any feed links in your <code>&lt;head&gt;</code>. Also, I read a <a href="http://core.trac.wordpress.org/ticket/12364" title="Deprecate automatic_feed_links() in favor of add_theme_support()">recent Trac ticket</a> that looked like this functionality was being integrated with <code>add_theme_support</code>, so keep your eyes open for that.</p>
<h3>Automatic jQuery inclusion</h3>
<p>We&rsquo;ve discussed <a href="http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/" title="Including jQuery in WordPress (The Right Way)">how to include jQuery the right way</a> by placing a little snippet in your document head, but here is a way to do it from your theme&rsquo;s <code>functions.php</code> file:</p>
<pre><code>// smart jquery inclusion
if (!is_admin()) {
	wp_deregister_script('jquery');
	wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"), false);
	wp_enqueue_script('jquery');
}</code></pre>
<p>This code ensures that only one copy of jQuery is included, and calls it from Google&rsquo;s servers to save bandwidth and take advantage of any primed caches that happen to be visiting. Note that this function needs to be located <em>before</em> the threaded-comments function in order for it to work.</p>
<h3>Enable threaded comments</h3>
<p>As we explain in <a href="http://digwp.com/book/" title="Get the Book!">the book</a>, enabling threaded comments requires adding a snippet of code into your <code>&lt;head&gt;</code> area just before the <code>wp_head</code> tag. After a little experimenting, I discovered that you can include this snippet from the <code>functions.php</code> file:</p>
<pre><code>// enable threaded comments
function enable_threaded_comments(){
	if (!is_admin()) {
		if (is_singular() AND comments_open() AND (get_option('thread_comments') == 1))
			wp_enqueue_script('comment-reply');
		}
}
add_action('get_header', 'enable_threaded_comments');</code></pre>
<p>This helps keep your document <code>&lt;head&gt;</code> a little cleaner. Note that this function needs to be located <em>after</em> the jQuery-inclusion function in order for it to work.</p>
<p>Thanks to <a href="http://soupgiant.com/">Peter Wilson</a> for this <a href="http://bigredtin.com/wordpress/including-wordpress-comment-reply-js/" title="Including WordPress' comment-reply.js (the right way)">awesome technique</a>!</p>
<h3>Remove unwanted crap from the head section</h3>
<p>As we&rsquo;ve <a href="http://digwp.com/2009/07/remove-wordpress-version-number/" title="How to Remove the WordPress Version Number (The Right Way)">mentioned before</a>, WordPress spits out a <em>ton</em> of crap in the document <code>&lt;head&gt;</code> &ndash; stuff like the version number and <acronym title="Windows Live Writer">WLW</acronym>, <acronym title="Really Simple Discovery">RSD</acronym>, and index links. To clean things up, we add this nice little snippet into the <code>functions.php</code> template:</p>
<pre><code>// remove junk from head
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);</code></pre>
<h3>Add Google Analytics to the footer</h3>
<p>Another annoying task that has to be done for all of the sites I create is adding Google Analytics code to the <code>footer.php</code> file. Recently it occurred to me to just add the code to my <code>functions.php</code> and never worry about it again:</p>
<pre><code>// add google analytics to footer
function add_google_analytics() {
	echo '&lt;script src="http://www.google-analytics.com/ga.js" type="text/javascript"&gt;&lt;/script&gt;';
	echo '&lt;script type="text/javascript"&gt;';
	echo 'var pageTracker = _gat._getTracker("UA-XXXXX-X");';
	echo 'pageTracker._trackPageview();';
	echo '&lt;/script&gt;';
}
add_action('wp_footer', 'add_google_analytics');</code></pre>
<p>A couple of notes here: first, obviously you want to replace the &ldquo;<code>UA-123456-1</code>&rdquo; with your actual <acronym title="Google Analytics">GA</acronym> code. Second, you may want to check out the <a href="http://perishablepress.com/press/2010/01/24/3-ways-track-google-analytics/" title="3 Ways to Track Web Pages with Google Analytics">three currently available Analytics options</a> and modify the code accordingly. Currently, this function is using the newer &ldquo;<code>ga.js</code>&rdquo; tracking code, but that is easily changed to either of the other methods.</p>
<h3>Custom excerpt length</h3>
<p>Instead of using the default 55-word limit, this function enables you to specify any length for your excerpts.</p>
<pre><code>// custom excerpt length
function custom_excerpt_length($length) {
	return 20;
}
add_filter('excerpt_length', 'custom_excerpt_length');</code></pre>
<p>Just set your preferred number of words by editing the &ldquo;<code>20</code>&rdquo; to whatever you wish.</p>
<h3>Custom excerpt &ldquo;continue&rdquo; string</h3>
<p>Or whatever they call that funky bracketed ellipses thing &ldquo;<code>[...]</code>&rdquo; that is appended to your post excerpts by default. I like to remove the brackets, but with this <code>functions.php</code> snippet you can change it to anything:</p>
<pre><code>// custom excerpt ellipses for 2.9+
function custom_excerpt_more($more) {
	return '...';
}
add_filter('excerpt_more', 'custom_excerpt_more');

/* custom excerpt ellipses for 2.8-
function custom_excerpt_more($excerpt) {
	return str_replace('[...]', '...', $excerpt);
}
add_filter('wp_trim_excerpt', 'custom_excerpt_more'); 
*/</code></pre>
<p>As you can see, there are two different versions of this code, depending on your version of WordPress. We like to stay current, so we commented out the older method but left it there in case you need it. For either version of this technique, just replace the &ldquo;<code>...</code>&rdquo; with &ldquo;pants on the ground&rdquo; or whatever happens to suit your needs.</p>
<h3>No &ldquo;more&rdquo; jumping for the &ldquo;read more&rdquo; link</h3>
<p>One of the weirdest things that WordPress does is &ldquo;jump&rdquo; the reader to the location of the &ldquo;<code>&lt;!--</code><code>more--&gt;</code>&rdquo; tag on the single-post-view when the &ldquo;read more&rdquo; link is clicked. It&rsquo;s just awkward &#8212; if the jump was on the <em>same</em> page, it would make sense, but to load a new page and then take the reader halfway down without explaining anything is just wrong. In any case, here is a nice little function that will stop the jumping once and for all:</p>
<pre><code>// no more jumping for read more link
function no_more_jumping($post) {
	return '&lt;a href="'.get_permalink($post-&gt;ID).'" class="read-more"&gt;'.'Continue Reading'.'&lt;/a&gt;';
}
add_filter('excerpt_more', 'no_more_jumping');
add_filter('the_content_more_link', 'remove_more_jump_link');</code></pre>
<p>Nothing else needs to be done for this to work &ndash; just plug it in and enjoy your new &ldquo;jumpless&rdquo; functionality. Note that this is also a convenient place to customize the &ldquo;read more&rdquo; link with whatever attributes or custom text you wish.</p>
<h3>Add a favicon to your blog</h3>
<p>You just <em>gotsta</em> have a favicon for your blog, and this code makes it super easy to do. Just create your image and upload to site&rsquo;s root directory. The following code in your <code>functions.php</code> file makes it so by adding the required line to your <code>&lt;head&gt;</code> area:</p>
<pre><code>// add a favicon to your 
function blog_favicon() {
	echo '&lt;link rel="Shortcut Icon" type="image/x-icon" href="'.get_bloginfo('wpurl').'/favicon.ico" /&gt;';
}
add_action('wp_head', 'blog_favicon');</code></pre>
<p>Feel free to change the directory to whatever you desire. Also make sure that the <code>wp_head</code> is present within your theme&rsquo;s <code>header.php</code> file.</p>
<h3>Add a different favicon for your blog&rsquo;s Admin area</h3>
<p>While we&rsquo;re here, let&rsquo;s add a unique favicon to our Admin pages, so that they are easier to recognize when bookmarked or working with tabs. Just create a favicon and upload to your theme&rsquo;s <code>/images/</code> directory. This code takes care of the rest:</p>
<pre><code>// add a favicon for your admin
function admin_favicon() {
	echo '&lt;link rel="Shortcut Icon" type="image/x-icon" href="'.get_bloginfo('stylesheet_directory').'/images/favicon.png" /&gt;';
}
add_action('admin_head', 'admin_favicon');</code></pre>
<p>As before, feel free to change the directory to whatever you desire. It might be best to keep your admin favicon in a separate directory than your blog favicon. Just sayin&rsquo;.</p>
<h3>Custom Admin Login logo</h3>
<p>You know that snazzy blue WordPress logo that is branding your various login pages? Yeh, you can change that to whatever you want. Just create your custom login image, name it &ldquo;<code>custom-login-logo.png</code>&rdquo;, and upload it to your theme&rsquo;s <code>/images/</code> directory. This code will take care of the rest:</p>
<pre><code>// custom admin login logo
function custom_login_logo() {
	echo '&lt;style type="text/css"&gt;
	h1 a { background-image: url('.get_bloginfo('template_directory').'/images/custom-login-logo.png) !important; }
	&lt;/style&gt;';
}
add_action('login_head', 'custom_login_logo');</code></pre>
<p>The key here is to make sure that the path and image names match that of your setup. Also, when creating your image, you may want to keep in mind the properties of the original: 30px length, 31px height, transparent <acronym title="Graphic Interchange Format">GIF</acronym> format, and header background color of #464646 (for the image matte).</p>
<h3>Disable unused widget areas</h3>
<p><a href="http://justintadlock.com/archives/2009/03/06/disable-widget-areas-without-touching-theme-templates" title="Disable widget areas (sidebars) without touching theme templates">Justin Tadlock</a> shares this handy function for removing unwanted widget areas from our theme &ndash; a <em>must</em> for customizing  existing themes:</p>
<pre><code>// disable all widget areas
function disable_all_widgets($sidebars_widgets) {
	//if (is_home())
		$sidebars_widgets = array(false);
	return $sidebars_widgets;
}
add_filter('sidebars_widgets', 'disable_all_widgets');</code></pre>
<p>This code is plug-&amp;-play &ndash; no other modifications need to be made. Note: if you only want to disable widgets on your Home page, then remove the two comment slashes (&ldquo;<code>//</code>&rdquo;) from the third line.</p>
<h3>Kill the WordPress update nag</h3>
<p>This is one of my favorites, but I know it&rsquo;s not for everyone. In any case, you know that &ldquo;Please update now..&rdquo; message that appears on every page in the WordPress Admin when new versions are available? This sweet little function kills it dead (or disables it, actually):</p>
<pre><code>// kill the admin nag
if (!current_user_can('edit_users')) {
	add_action('init', create_function('$a', "remove_action('init', 'wp_version_check');"), 2);
	add_filter('pre_option_update_core', create_function('$a', "return null;"));
}</code></pre>
<p>Feel free to comment this one out or remove it if you rely on the Admin nag to keep you informed of changes.</p>
<h3>Include category ID in body_class and post_class</h3>
<p>By default, WordPress <code>body_class</code> and <code>post_class</code> do not include the ID of the category of the current post. This custom function changes all that:</p>
<pre><code>// category id in body and post class
function category_id_class($classes) {
	global $post;
	foreach((get_the_category($post-&gt;ID)) as $category)
		$classes [] = 'cat-' . $category-&gt;cat_ID . '-id';
		return $classes;
}
add_filter('post_class', 'category_id_class');
add_filter('body_class', 'category_id_class');</code></pre>
<p>Even if you aren&rsquo;t using it, it&rsquo;s a nice function to have around, which is why it&rsquo;s included here for this custom <code>functions.php</code> template of essential functions. Keywords in the house because we can.</p>
<h3>Get the first category ID</h3>
<p>Another useful function when working with different categories is the ability to get the first category ID of the current post. This function makes it happen:</p>
<pre><code>// get the first category id
function get_first_category_ID() {
	$category = get_the_category();
	return $category[0]-&gt;cat_ID;
}</code></pre>
<p>Strictly plug-&amp;-play: just use <code>&lt;?php get_first_category_ID(); ?&gt;</code> in your theme template file to access the data.</p>
<h3>Putting it all together..</h3>
<p>As promised, here is the full-meal deal &ndash; the entire collection neatly organized into a single chunk of code:</p>
<pre><code>&lt;?php // custom functions.php template @ digwp.com

// add feed links to header
if (function_exists('automatic_feed_links')) {
	automatic_feed_links();
} else {
	return;
}


// smart jquery inclusion
if (!is_admin()) {
	wp_deregister_script('jquery');
	wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"), false, '1.3.2');
	wp_enqueue_script('jquery');
}


// enable threaded comments
function enable_threaded_comments(){
	if (!is_admin()) {
		if (is_singular() AND comments_open() AND (get_option('thread_comments') == 1))
			wp_enqueue_script('comment-reply');
		}
}
add_action('get_header', 'enable_threaded_comments');


// remove junk from head
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);


// add google analytics to footer
function add_google_analytics() {
	echo '&lt;script src="http://www.google-analytics.com/ga.js" type="text/javascript"&gt;&lt;/script&gt;';
	echo '&lt;script type="text/javascript"&gt;';
	echo 'var pageTracker = _gat._getTracker("UA-XXXXX-X");';
	echo 'pageTracker._trackPageview();';
	echo '&lt;/script&gt;';
}
add_action('wp_footer', 'add_google_analytics');


// custom excerpt length
function custom_excerpt_length($length) {
	return 20;
}
add_filter('excerpt_length', 'custom_excerpt_length');


// custom excerpt ellipses for 2.9+
function custom_excerpt_more($more) {
	return '...';
}
add_filter('excerpt_more', 'custom_excerpt_more');

/* custom excerpt ellipses for 2.8-
function custom_excerpt_more($excerpt) {
	return str_replace('[...]', '...', $excerpt);
}
add_filter('wp_trim_excerpt', 'custom_excerpt_more'); 
*/


// no more jumping for read more link
function no_more_jumping($post) {
	return '&lt;a href="'.get_permalink($post-&gt;ID).'" class="read-more"&gt;'.'Continue Reading'.'&lt;/a&gt;';
}
add_filter('excerpt_more', 'no_more_jumping');


// add a favicon to your 
function blog_favicon() {
	echo '&lt;link rel="Shortcut Icon" type="image/x-icon" href="'.get_bloginfo('wpurl').'/favicon.ico" /&gt;';
}
add_action('wp_head', 'blog_favicon');


// add a favicon for your admin
function admin_favicon() {
	echo '&lt;link rel="Shortcut Icon" type="image/x-icon" href="'.get_bloginfo('stylesheet_directory').'/images/favicon.png" /&gt;';
}
add_action('admin_head', 'admin_favicon');


// custom admin login logo
function custom_login_logo() {
	echo '&lt;style type="text/css"&gt;
	h1 a { background-image: url('.get_bloginfo('template_directory').'/images/custom-login-logo.png) !important; }
	&lt;/style&gt;';
}
add_action('login_head', 'custom_login_logo');


// disable all widget areas
function disable_all_widgets($sidebars_widgets) {
	//if (is_home())
		$sidebars_widgets = array(false);
	return $sidebars_widgets;
}
add_filter('sidebars_widgets', 'disable_all_widgets');


// kill the admin nag
if (!current_user_can('edit_users')) {
	add_action('init', create_function('$a', "remove_action('init', 'wp_version_check');"), 2);
	add_filter('pre_option_update_core', create_function('$a', "return null;"));
}


// category id in body and post class
function category_id_class($classes) {
	global $post;
	foreach((get_the_category($post-&gt;ID)) as $category)
		$classes [] = 'cat-' . $category-&gt;cat_ID . '-id';
		return $classes;
}
add_filter('post_class', 'category_id_class');
add_filter('body_class', 'category_id_class');


// get the first category id
function get_first_category_ID() {
	$category = get_the_category();
	return $category[0]-&gt;cat_ID;
}

?&gt;</code></pre>
<h3 id="functions-download">Download the custom functions.php template file</h3>
<p>If you prefer, you can download this code in a ready-to-go <code>functions.php</code> file in zipped format:</p>
<h4><a href="http://digwp.com/plugins/custom-functions-template.zip">Download zipped functions.php Template File</a></h4>
<h3>Also..</h3>
<p>If this post is useful to <acronym title="Digging into WordPress">DiW</acronym> readers, I&rsquo;ll be writing up another article (part 2) with even more useful custom functions. If that happens, the second set of functions will include some slightly more advanced techniques as opposed to these &ldquo;must-have&rdquo; template functions. <a href="http://feeds2.feedburner.com/DiggingIntoWordpress" title="Grab the Feed!">Stay tuned</a>! <strong>Update:</strong> <a href="http://digwp.com/2010/04/wordpress-custom-functions-php-template-part-2/" title="WordPress Custom functions.php Template, Part 2">Custom functions.php Part 2 is here</a>!</p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/03/wordpress-functions-php-template-custom-functions/">Permalink</a> | <a href="http://digwp.com/2010/03/wordpress-functions-php-template-custom-functions/#comments">80 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/03/wordpress-functions-php-template-custom-functions/&title=WordPress functions.php Template with 15 Essential Custom Functions">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/template/" rel="tag">template</a>, <a href="http://digwp.com/tag/theme/" rel="tag">Theme</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/03/wordpress-functions-php-template-custom-functions/feed/</wfw:commentRss>
		<slash:comments>80</slash:comments>
		</item>
	</channel>
</rss>

