<?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>Kim Maida &#124; Blog</title>
	<atom:link href="http://blog.kim-maida.com/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.kim-maida.com</link>
	<description>Resources and Downloads for the discerning Web Designer</description>
	<lastBuildDate>Tue, 08 May 2012 14:52:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>KM Front-End Kit with PHP</title>
		<link>http://blog.kim-maida.com/web-development/km-front-end-kit-v1-3-with-php</link>
		<comments>http://blog.kim-maida.com/web-development/km-front-end-kit-v1-3-with-php#comments</comments>
		<pubDate>Fri, 20 Apr 2012 12:00:42 +0000</pubDate>
		<dc:creator>Kim</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[FREE]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[responsive design]]></category>

		<guid isPermaLink="false">http://blog.kim-maida.com/?p=791</guid>
		<description><![CDATA[The KM Front-End Kit has been revamped for PHP! Download this HTML5 / CSS3 / jQuery front-end kit to get you started as quickly and easily as possible with your next responsive design front-end development project.

The kit has been updated to use PHP includes and variables for a more abstracted, dynamic development experience.]]></description>
			<content:encoded><![CDATA[<p>The kit includes the following files. Modify or delete the files however you see fit.</p>
<ul>
<li><strong>/images</strong></li>
<li><strong>/includes</strong>
<ul>
<li>header.php – <em>HTML5 shim, js FOUC fix, conditional body classes for styling versions of IE, page title variable</em></li>
<li>footer.php – <em>jQuery, media queries shim, Google Analytics</em></li>
<li>mobile_detect.php – <em>PHP class to detect mobile devices, for responsive design</em></li>
</ul>
</li>
<li><strong>/js</strong>
<ul>
<li>script.js – <em>jQuery</em></li>
</ul>
</li>
<li><strong>/styles</strong>
<ul>
<li>styles.css – <em>CSS reset and some basic styles, practical media queries for a mobile first approach, print styles</em></li>
</ul>
</li>
<li>index.php – <em>Page title and active page variables, includes</em></li>
<li>subpage.php – <em>Page title and active page variables, includes</em></li>
<li>ReadMe (pdf)</li>
</ul>
<p>This kit will be updated periodically. Please keep an eye out for updates!</p>
<h2>Changelog</h2>
<ul>
<li><em>Apr. 20, 2012</em> &#8211; updated to v1.3.3: edited the viewport meta to permit user scaling, added caution regarding the use of mobile detection PHP class, deleted comprehensive media queries examples, edited existing media queries to use a mobile-first approach<br />
<em></em></li>
<li><em>Feb. 9, 2012</em> &#8211; updated to v.1.3.2: added mobile detection PHP class, tweaked media queries for more consistent rendering</li>
<li><em>Feb. 7, 2012</em> &#8211; updated to v.1.3.1: removed nav.php and integrated into header, integrated a few select practical media queries and print styles into main stylesheet to reduce HTTP requests, updated jQuery version to 1.7.x, minor code clean-up</li>
</ul>
<p>If PHP isn&#8217;t your thing, the plain HTML version of the kit can be downloaded at <a href="http://blog.kim-maida.com/web-development/km-front-end-kit-v1-3">KM Front-End Kit v1.3</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kim-maida.com/web-development/km-front-end-kit-v1-3-with-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Author Bio on Posts</title>
		<link>http://blog.kim-maida.com/web-development/wordpress/wordpress-author-bio-on-posts</link>
		<comments>http://blog.kim-maida.com/web-development/wordpress/wordpress-author-bio-on-posts#comments</comments>
		<pubDate>Thu, 26 Jan 2012 17:28:46 +0000</pubDate>
		<dc:creator>Kim</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[quick tips]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.kim-maida.com/?p=803</guid>
		<description><![CDATA[If you have a WordPress blog with multiple authors, you may find that it would be helpful to display an author blurb/bio somewhere on each post. Here are some instructions to do this using the <a href="http://codex.wordpress.org/Function_Reference/get_template_part">get_template_part()</a> function. I am also including instructions on how to update your author contact methods, since the fields built in by WordPress are a bit outdated (AIM, YIM, Jabber).]]></description>
			<content:encoded><![CDATA[<p>If you have a WordPress blog with multiple authors, you may find that it would be helpful to display an author blurb/bio somewhere on each post. Here are some instructions to do this using the <a href="http://codex.wordpress.org/Function_Reference/get_template_part">get_template_part()</a> function. I am also including instructions on how to update your author contact methods, since the fields built in by WordPress are a bit outdated (AIM, YIM, Jabber).</p>
<h2>Change the Author Contact Methods</h2>
<p>The first thing we&#8217;ll do is update the author contact methods. These are fields that are filled in by the user in their User Profile in the back end. By default, they include the user&#8217;s e-mail (required), website, AIM, Yahoo IM, and Jabber/Google Talk. For this example, I&#8217;m going to replace AIM, YIM, and Jabber with Facebook, Twitter, Google+, and LinkedIn, but you can use whichever networks you&#8217;d prefer.</p>
<p>Open your theme&#8217;s <strong>functions.php</strong> file and add the following:</p>
<pre class="brush: php; title: functions.php; toolbar: false; notranslate">// Update Author Contact Info
function change_contact_info($contactmethods) {
	unset($contactmethods['aim']);
	unset($contactmethods['yim']);
	unset($contactmethods['jabber']);
	$contactmethods['facebook'] = 'Facebook URL';
	$contactmethods['googleplus'] = 'Google+ URL';
	$contactmethods['twitter'] = 'Twitter Username';
	$contactmethods['linkedin'] = 'LinkedIn Username';

	return $contactmethods;
}
add_filter('user_contactmethods', 'change_contact_info');</pre>
<p>Note that I am prompting the user for full URIs for Facebook and Google+ versus usernames for twitter and LinkedIn. This is done because of the way these networks currently format their users&#8217; profile URIs. </p>
<p>Some Facebook users have set a pretty URI, but some have not: therefore, we cannot rely on this always being the case, so to be safe, we&#8217;re asking for the full URI. This also allows flexibility for people to provide links to FB pages rather than strictly user profiles. </p>
<p>Google+ uses a numerical ID, but since this is a very long string of numbers, it&#8217;s probably easier for users to simply copy and paste the entire URI. In addition, they now also have the option to use the links provided by short URL services like <a href="http://gplus.to">gplus.to</a> if they&#8217;ve chosen to set something like that up.</p>
<p>It&#8217;s important to make note of this because it will affect how you need to display the author meta information in your theme files.</p>
<h2>Create an Author Bio template part</h2>
<p>Now we want to take the author meta information and display it on a per-post basis. To do this, we&#8217;ll create a <a href="http://codex.wordpress.org/Function_Reference/get_template_part">template part</a>, aka WordPress&#8217;s tag for a PHP include.</p>
<p>Create a new PHP file in your theme and name it <strong>bio-author.php</strong>. This can be called something else if you prefer, but I named it thusly to make sure it isn&#8217;t going to interfere with the naming schemes of any of the other theme files. </p>
<p><strong>Note:</strong> Do <em>not</em> name your template part <em>author-bio.php</em>! This will cause WordPress to interpret the file as the Author page for a user with the nicename &#8220;Bio&#8221;. If you need a refresher on how the WordPress theme hierarchy works, take a look at the <a href="http://wp.tutsplus.com/articles/wordpress-cheat-sheets-template-heirarchy-map/">WordPress Template Hierarchy Map cheat sheet</a>.</p>
<p>In your <strong>bio-author.php</strong> file, write the code to display the author bio you want to include on each post.</p>
<pre class="brush: php; title: bio-author.php; toolbar: false; notranslate">&lt;div id=&quot;author-bio&quot; class=&quot;author-bio&quot;&gt;
	&lt;?php echo get_avatar( get_the_author_meta('ID'), 80 ); ?&gt;
	&lt;p class=&quot;author-name&quot;&gt;
		Author: &lt;strong&gt;&lt;?php the_author_posts_link(); ?&gt;&lt;/strong&gt;
		&lt;?php if (get_the_author_meta('user_url')) {
			echo '| &lt;a href=&quot;' . get_the_author_meta('user_url') . '&quot;&gt;website&lt;/a&gt;';
		}
		if (get_the_author_meta('twitter')) {
			echo '| &lt;a href=&quot;http://twitter.com/' . get_the_author_meta('twitter') . '&quot;&gt;twitter&lt;/a&gt;';
		} ?&gt;
	&lt;/p&gt;
	&lt;p class=&quot;author-description&quot;&gt;&lt;?php the_author_meta(user_description); ?&gt;&lt;/p&gt;
&lt;/div&gt;</pre>
<p>The above code will print the author&#8217;s <a href="http://codex.wordpress.org/Function_Reference/get_avatar">Gravatar</a> and <a href="http://codex.wordpress.org/Function_Reference/the_author_posts_link">public display name with a link to their author page</a>. If the user has filled in a website URL and twitter username, it will display these with links, separated by pipes. It then displays the user&#8217;s description.</p>
<p>You can edit this code to display other parts of the author meta by using the <a href="http://codex.wordpress.org/Template_Tags/the_author_meta">the_author_meta()</a> template tag (displays the information) and the <a href="http://codex.wordpress.org/Function_Reference/get_the_author_meta">get_the_author_meta()</a> function (returns the information but does not display it, useful for creating links to the new contact methods we set up).</p>
<h2>Include the template part on single posts</h2>
<p>We&#8217;re now ready to include the author bio with our posts. Go to your <strong>single.php</strong> and/or <strong>single-{post-type}.php</strong> file(s) and place the template part where you&#8217;d like the bio to be included:</p>
<pre class="brush: php; title: single-posttype.php; toolbar: false; notranslate">&lt;?php get_template_part('bio','author'); ?&gt;</pre>
<p><strong>Note:</strong> This must be placed <em>inside the loop</em>, otherwise it will not know who the author is and will not work. I like to place it between the post content and the comments.</p>
<p>As you can see, the <a href="http://codex.wordpress.org/Function_Reference/get_template_part">get_template_part()</a> function works by using the parts of the hyphenated file name to include the appropriate file. You can see how this would be useful if you group your theme&#8217;s template parts by related pieces (this can be seen in action in the default WordPress TwentyEleven theme as well as my <a href="http://blog.kim-maida.com/web-development/wordpress/wordpress-html5-theme">HTML5 Blank Theme</a>).</p>
<p>Finally, use your theme&#8217;s <em>styles.css</em> to style the author bio appropriately.</p>
<h3>One more thing: Author Pages</h3>
<p>If your theme does not have an Author template (<strong>author.php</strong>), you should look into creating one. The <a href="http://codex.wordpress.org/Author_Templates">Author Templates</a> entry in the WordPress Codex will help you get started. You can also ensure that an author&#8217;s custom post types are listed on their page by using the method here: <a href="http://blog.kim-maida.com/web-development/wordpress/wp-authors-custom-post-types">WP Authors Custom Post Types</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kim-maida.com/web-development/wordpress/wordpress-author-bio-on-posts/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Login/out Redirects</title>
		<link>http://blog.kim-maida.com/web-development/wordpress/wordpress-loginout-redirects</link>
		<comments>http://blog.kim-maida.com/web-development/wordpress/wordpress-loginout-redirects#comments</comments>
		<pubDate>Tue, 10 Jan 2012 18:04:58 +0000</pubDate>
		<dc:creator>Kim</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[quick tips]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://blog.kim-maida.com/?p=765</guid>
		<description><![CDATA[Many times in the past, I have found myself logging into my blog via the Log in link in my sidebar when I want to update a post. Upon logging in, WordPress would send me to the dashboard. Instead, I would have preferred for WordPress to keep me on the same page I logged in from. To fix this, you can use WordPress's functions to set up your theme's login and log out links to send the user wherever you'd like.]]></description>
			<content:encoded><![CDATA[<p>Many times in the past, I have found myself logging into my blog via the Log in link in my sidebar when I want to update a post. Upon logging in, WordPress would send me to the dashboard. Instead, I would have preferred for WordPress to keep me on the same page I logged in from. To fix this, you can use WordPress&#8217;s functions to set up your theme&#8217;s login and log out links to send the user wherever you&#8217;d like.</p>
<p>The simple, classic way of handling login / log out links in WordPress is to place the following code where you want the link to appear:</p>
<pre class="brush: php; title: Login / Log out; toolbar: false; notranslate">&lt;?php wp_loginout(); ?&gt;</pre>
<p>This generates a &#8220;Log in&#8221; link when the user is logged out, and a &#8220;Logout&#8221; link when the user is logged in. The &#8220;Log in&#8221; link redirects to the dashboard once the user has inputted their username and password successfully, and the &#8220;Log out&#8221; link redirects to the Login screen.</p>
<h2>Redirect login / log out</h2>
<p>The <a href="http://codex.wordpress.org/Function_Reference/wp_loginout">wp_loginout()</a> function accepts a <em>$redirect</em> parameter that can send the user to a location other than the defaults.</p>
<p>To send the user to a specific page upon logging in or out, specify a redirect:</p>
<pre class="brush: php; title: Login / log out Redirect; toolbar: false; notranslate">&lt;?php wp_loginout( site_url() ); ?&gt;</pre>
<p>The above code sends the user to your site (<em>site_url()</em> for home, or use <em>site_url(&#8216;/mypage&#8217;)</em> for a page of your site) after they&#8217;ve been logged in or out. You can also use an absolute URL in quotes. You may even use <em>get_permalink()</em> to send them to the &#8220;current&#8221; page they logged in or out from.</p>
<h2>Redirect login and log out separately</h2>
<p>You can also set different redirects for your login and log out links using the <a href="http://codex.wordpress.org/Function_Reference/is_user_logged_in">is_user_logged_in()</a> function along with <a href="http://codex.wordpress.org/Function_Reference/wp_login_url">wp_login_url()</a> and <a href="http://codex.wordpress.org/Function_Reference/wp_logout_url">wp_logout_url()</a>.</p>
<p><em>is_user_logged_in()</em> is a boolean that returns a true/false value. Therefore, we can use it to hide or display login / log out / admin links. Here is an example of how this is used:</p>
<pre class="brush: php; title: Check if the user is logged in; toolbar: false; notranslate">&lt;?php if (is_user_logged_in()) { ?&gt;
	&lt;!-- User is logged in: show Admin and Log out link --&gt;
&lt;?php } else { ?&gt;
	&lt;!-- User is logged out: show Log in link --&gt;
&lt;?php } ?&gt;</pre>
<p>To use <em>is_user_logged_in()</em> to show an admin and log out link to a user if they are logged in and a login link only if the user is not logged in:</p>
<pre class="brush: php; title: Login and Log out with different redirects; toolbar: false; notranslate">&lt;ul&gt;
	&lt;?php if (is_user_logged_in()) { ?&gt;
		&lt;li&gt;&lt;a href=&quot;&lt;?php home_url(); ?&gt;/wp-admin&quot;&gt;Admin&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;&lt;?php echo wp_logout_url( site_url() ); ?&gt;&quot;&gt;Log out&lt;/a&gt;&lt;/li&gt;
	&lt;?php } else { ?&gt;
		&lt;li&gt;&lt;a href=&quot;&lt;?php echo wp_login_url( get_permalink() ); ?&gt;&quot;&gt;Log in&lt;/a&gt;&lt;/li&gt;
	&lt;?php } ?&gt;
&lt;/ul&gt;</pre>
<p>The log in redirects back to the current page, whereas the log out link redirects to the home page. This is the method I personally prefer. As shown above, this link can be a WordPress tag or it can be an <em>absolute</em> URI (including <em>http://</em>). Relative URIs will not work.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kim-maida.com/web-development/wordpress/wordpress-loginout-redirects/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress functions.php File</title>
		<link>http://blog.kim-maida.com/web-development/wordpress/wordpress-functions-php-file</link>
		<comments>http://blog.kim-maida.com/web-development/wordpress/wordpress-functions-php-file#comments</comments>
		<pubDate>Fri, 06 Jan 2012 19:38:18 +0000</pubDate>
		<dc:creator>Kim</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[quick tips]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.kim-maida.com/?p=665</guid>
		<description><![CDATA[So you've got a <a href="http://wordpress.org">WordPress</a> theme that you're either creating for the first time, or that you'd like to edit to suit your needs. You want to modify your theme's functionality or add features&#8212; where to start? 

This is a beginner's introduction to the <em>functions.php</em> file in WordPress themes. You do not need experience in PHP to follow along, though you should have solid knowledge of HTML/CSS and be familiar with <em>using</em> WordPress.]]></description>
			<content:encoded><![CDATA[<p>So you&#8217;ve got a <a href="http://wordpress.org">WordPress</a> theme that you&#8217;re either creating for the first time, or that you&#8217;d like to edit to suit your needs. You want to modify your theme&#8217;s functionality or add features&mdash; where to start? </p>
<p>This is a beginner&#8217;s introduction to the <em>functions.php</em> file in WordPress themes. You do not need experience in PHP to follow along, though you should have solid knowledge of HTML/CSS and be familiar with <em>using</em> WordPress.</p>
<h2>What is <em>functions.php</em>?</h2>
<p>The WordPress <strong>functions.php</strong> file is located in your theme&#8217;s directory (<em>/wp-content/themes/your-theme/functions.php</em>). The <a href="http://codex.wordpress.org/Theme_Development#Functions_File">functions file</a> is essentially a within-theme plugin. It is run during WordPress initialization on both the front and back ends, therefore enabling you to add features and customization specific to your theme.</p>
<p>WordPress contains numerous <a href="http://codex.wordpress.org/Function_Reference" title="WordPress Function Reference">functions</a> that you can take advantage of or alter / <a href="http://codex.wordpress.org/Function_Reference/add_filter" title="WordPress add_filter">filter</a> in your theme. You may, of course, also create your own functions in the <em>functions.php</em> file.</p>
<p>If you are relatively new to PHP and WordPress, it&#8217;s best to start with function snippets that have been written by other WordPress developers before you attempt to write your own custom functions. There are many commonly-used functions that should cover nearly all of your basic needs for theme customization. When you&#8217;ve thoroughly familiarized yourself with WordPress and learned some PHP, then you can tackle writing your own functions and plugins for more advanced customization.</p>
<h2>Plugin or <em>functions.php</em>?</h2>
<p>The key difference between putting your code in the <em>functions.php</em> file as opposed to writing a plugin is that plugins are independent from themes. If you are writing in features that are closely tied to other theme files (such as specially-styled post formats, for example), you should use <em>functions.php</em>. This way, the feature, its styles, and its code come packaged with your theme.</p>
<p>The advantage to plugins, alternately, is that they can be activated and deactivated on the fly, and will be persistent when the user changes themes. They can have their own outputted code and styles, all contained within the plugin files, which will be applied, regardless of theme. </p>
<p>It is a judgment call on what route is more appropriate for your needs. However, it is generally accepted that post thumbnails, post formats, custom comment callbacks, and similar theme-related features should be in the <em>functions.php</em> file. </p>
<h2>Writing <em>functions.php</em> from scratch</h2>
<p>If you are writing a functions file from scratch, create a new <em>.php</em> file in your theme&#8217;s directory and call it <em>functions.php</em>. </p>
<p><strong>PHP 101:</strong> PHP scripts need to be contained within <em>PHP delimiters</em>, because although the server knows to look for PHP script in a <em>.php</em> file, these files can also contain non-PHP elements. Anything outside PHP delimiters will be interpreted as plain text or HTML.</p>
<p>All functions should go between the delimiters, like so:</p>
<pre class="brush: php; title: functions.php; toolbar: false; notranslate">&lt;?php
	// all functions will go here
?&gt;</pre>
<p><strong>Note:</strong> When you are searching online for functions, some sites and blogs will include the delimiters. Others will leave them off, assuming that you know to include them at the beginning and end of the file.</p>
<h2>&#8220;Must-have&#8221; Features</h2>
<p>Here are a few features (as of <a href="http://wordpress.org/news/2011/12/sonny/">WordPress 3.3, aka &#8220;Sonny&#8221;</a>) that every theme should seriously consider supporting.</p>
<p><strong>Note:</strong> You will want to check if the function exists first for newer features, in case the installation of WordPress is older and doesn&#8217;t support the feature yet. This is done by enclosing the function in <em>if (function_exists()) { &#8230; }</em> (see examples below).</p>
<h3><strong>Menus</strong></h3>
<p>&#8220;Menus&#8221; are dynamic areas that users can populate with pages, posts, archives, etc. of their choosing via settings (<em>Appearance / Menus</em> on the back end). They are created using the <a href="http://codex.wordpress.org/Function_Reference/register_nav_menus">register_nav_menus()</a> function.</p>
<p><strong>PHP 101:</strong> You can have more than one menu area if you wish, so the function supports an <em>array</em>. Arrays are PHP datatypes that can store multiple pieces of information. </p>
<p><strong>WP workings:</strong> If you only want one menu, you can still set up the function the same way. Use an array, but only include one menu in it. Alternately: there is a function in WordPress that generates a single menu (<a href="http://codex.wordpress.org/Function_Reference/register_nav_menu">register_nav_menu()</a>), with a shortened format. However, behind the scenes it is actually still using the <em>register_nav_menu<strong>s</strong>()</em> array with only one value. Therefore, it is up to you which option you choose: the outcome is still the same.</p>
<p>You will need to name your menus appropriately, because these names will show up on the back end as customizable areas.</p>
<pre class="brush: php; title: functions.php - Menus; toolbar: false; notranslate">// Register menus
if ( function_exists( 'register_nav_menus' ) ) {
	register_nav_menus( array(
		'primary' =&gt; __( 'Primary Navigation' ),
		'secondary' =&gt; __( 'Secondary Navigation' )
	));
}</pre>
<p><strong>PHP 101:</strong> The <em>__( $string )</em> format is an international translation aid. If you were to leave it off and put something like <em>&#8216;primary&#8217; => &#8216;Primary Navigation&#8217;</em> instead, the text would print exactly as it is, even if the WordPress installation&#8217;s language was changed.</p>
<p><strong>To display menus on the front end</strong>, you would place the following in your theme file:</p>
<pre class="brush: php; title: Theme File; toolbar: false; notranslate">&lt;?php wp_nav_menu( array('menu' =&gt; 'Primary Navigation' )); ?&gt;</pre>
<p>By default, this outputs a container div with a class of &#8220;menu-{menu-slug}-container&#8221;, a ul tag with a class of &#8220;menu&#8221;, and then encloses each item inside the menu in li tags with additional classes generated by WP. </p>
<p>This is robust HTML output that is easily customizable with CSS, but if you wish to change the way this code is outputted, you should consult the <a href="http://codex.wordpress.org/Function_Reference/wp_nav_menu">wp_nav_menu()</a> function reference.</p>
<h3><strong>Dynamic Sidebar</strong></h3>
<p>Dynamic sidebars support &#8220;widgets&#8221;. <a href="http://codex.wordpress.org/WordPress_Widgets">Widgets</a> are chunks of content, interaction, etc. that can be customized by dragging and dropping into dynamic sidebar areas on the back end. WordPress comes packaged with some of its own widgets (such as tag clouds, post categories, etc.) and many plugins also provide widgets.</p>
<pre class="brush: php; title: functions.php - Dynamic Sidebar; toolbar: false; notranslate">// Add support for dynamic sidebar
if (function_exists('register_sidebar')) {
	register_sidebar(array(
		'name' =&gt; 'Navigation'
	));
}</pre>
<p>You may register additional sidebars by repeating the <em>register_sidebar()</em> function and assigning different names. (<a href="http://codex.wordpress.org/Function_Reference/register_sidebar">More information on the register_sidebar() array</a>.)</p>
<p><strong>To display sidebars on the front end</strong>, place the following code in your <em>sidebar.php</em> file:</p>
<pre class="brush: php; title: sidebar.php; toolbar: false; notranslate">
&lt;ul&gt;
	&lt;?php dynamic_sidebar('Navigation') ?&gt;
&lt;/ul&gt;</pre>
<p>You can also place static content that will be loaded if no dynamic content has been placed, or if widgets are inactive. This can be done like so:</p>
<pre class="brush: php; title: sidbear.php with static content; toolbar: false; notranslate">&lt;ul&gt;
	&lt;?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?&gt;
	&lt;li&gt;Static Content&lt;/li&gt;
	&lt;?php endif; ?&gt;
&lt;/ul&gt;</pre>
<p>By default, the sidebar widgets will output a container li with an H2 heading title. You can edit the HTML output by modifying the parameters specified at <a href="http://codex.wordpress.org/Function_Reference/register_sidebar">register_sidebar()</a>.</p>
<h2>Add Theme Support</h2>
<p>Another great use for the <em>functions.php</em> file is <em>adding theme support</em>. The <a href="http://codex.wordpress.org/Function_Reference/add_theme_support">add_theme_support()</a> function allows you to take advantage of some of the optional features WordPress boasts. New WP releases occasionally add new theme features that need to be initialized via the <em>functions.php</em> file if you wish to use them.</p>
<h3><strong>Post Thumbnails</strong></h3>
<p>Also known as &#8220;Featured Images&#8221; (this is what the post meta box is titled), post thumbnails are images that &#8220;represent&#8221; the post and can be displayed in loops. In the past, featured images have been implemented using WordPress&#8217;s custom fields capabilities, but now the feature has been built in and can be used via the following functions:</p>
<pre class="brush: php; title: functions.php - Post Thumbnails; toolbar: false; notranslate">// Add support for Featured Images
if (function_exists('add_theme_support')) {
	add_theme_support('post-thumbnails');
	// (name of the thumbnail, width, height, crop mode)
	set_post_thumbnail_size(150, 100, true);	// Default thumbnail for loop.
	add_image_size('featured-single', 400, 600, false);	// The thumbnail in the single post, linking to the full-size image.
}

// Generate link to full-size image
function get_image_url( $image_id, $image_size ) {
	$image = wp_get_attachment_image_src( $image_id, $image_size );
	return $image[0];
}</pre>
<p>With these functions, we have now generated a hard-cropped <em>default post thumbnail</em> (150px x 100px), a soft-proportioned <em>large thumbnail</em> (400px x 600px), and a <em>link</em> to the uploaded full-size image file. </p>
<p><strong>To display featured images on the front end</strong>, you can modify a few different theme files depending on where you&#8217;d like your featured images to show up. </p>
<p>To display the default post thumbnail with a link to the full post in archive, index, search results, or other queried loops, use the following:</p>
<pre class="brush: php; title: Listing Loops - Post Thumbnail; toolbar: false; notranslate">&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; title=&quot;&lt;?php the_title(); ?&gt;&quot;&gt;
	&lt;?php the_post_thumbnail(); ?&gt;
&lt;/a&gt;</pre>
<p>To display the large thumbnail within a post with a link to view the full-size version, try placing something like this in your <em>single.php</em> file inside the loop, wherever you wish the image to display (normally this is done right above the post content</em>):</p>
<pre class="brush: php; title: single.php - Post Thumbnail; toolbar: false; notranslate">&lt;?php if ( has_post_thumbnail() ) :
	$image_id = get_post_thumbnail_id();
	$image_url = get_image_url( $image_id, 'full' );
?&gt;
	&lt;a href=&quot;&lt;?php echo $image_url; ?&gt;&quot; title=&quot;&lt;?php the_title(); ?&gt; (view larger)&quot;&gt;&lt;?php the_post_thumbnail('featured-single'); ?&gt;&lt;/a&gt;
&lt;?php endif; ?&gt;</pre>
<p>Default post thumbnails output with an image class of &#8220;attachment-post-thumbnail&#8221;. Additional image sizes (like our example &#8220;featured-single&#8221; image) output with a class of &#8220;attachment-{thumbnail-name}&#8221;.</p>
<h3><strong>Other&#8230;</strong></h3>
<p>You can also add automatic feed links and post formats with <a href="http://codex.wordpress.org/Function_Reference/add_theme_support">add_theme_support</a>. Most themes benefit from <a href="http://codex.wordpress.org/Function_Reference/add_theme_support#Feed_Links">Feed Links</a>, but I feel that <a href="http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Formats">Post Formats</a> are a more specialized option and do not qualify as &#8220;must-have&#8221;s. </p>
<h2>Custom Editor Styles</h2>
<p>Another exciting new feature is the ability to change the styles of the TinyMCE editor field that WordPress uses to create page and post content. This helps to bridge the gap between what you put into the editor and what you see on your site, making it more of a true &#8220;What You See Is What You Get&#8221; experience.</p>
<p>To enable this functionality, add the following to your <em>functions.php</em> file:</p>
<pre class="brush: php; title: functions.php - Editor Styles; toolbar: false; notranslate">// Add support for TinyMCE custom editor stylesheet
if (function_exists('add_editor_style')) { add_editor_style( 'editor-style.css' ); }</pre>
<p><strong>To display editor styles</strong>, you now need to add a stylesheet to your theme&#8217;s root folder called <em>editor-style.css</em>. Add any styles that you want to show up in the WYSIWYG editor.</p>
<h2>Change the Excerpt [...] to a Permalink</h2>
<p>When you use <a href="http://codex.wordpress.org/Function_Reference/the_excerpt">the_excerpt()</a>, content that exceeds the excerpt maximum length will be cut off and replaced with [...]. This is not a link, it is simply an indicator that more content exists.</p>
<p>If you wish to use <em>the_excerpt</em> and would like the [...] converted into a permalink to the full post, you can add the following to your <em>functions.php</em> file:</p>
<pre class="brush: php; title: functions.php - Excerpt Permalink; toolbar: false; notranslate">// Replace excerpt [...] with permalink
function replace_excerpt($content) {
	return str_replace('[...]',
		'&lt;a class=&quot;more-link&quot; href=&quot;'. get_permalink() .'&quot;&gt;read more &amp;raquo;&lt;/a&gt;',
			$content
	);
}
add_filter('the_excerpt', 'replace_excerpt');</pre>
<h2>Custom Comments Callback</h2>
<p>By default, WordPress generates the HTML for displaying comments. However, theme-makers frequently wish to modify this code to their own liking. This can be done by adding a custom callback to the <a href="http://codex.wordpress.org/Function_Reference/wp_list_comments">wp_list_comments()</a> function.</p>
<p>Add your customized comment HTML to your <em>functions.php</em> file:</p>
<pre class="brush: php; title: functions.php - Custom Comments Callback; toolbar: false; notranslate">// Custom callback for threaded comments to permit HTML editing
function cc_callback($comment, $args, $depth) {
	$GLOBALS['comment'] = $comment; ?&gt;
		&lt;li id=&quot;li-comment-&lt;?php comment_ID() ?&gt;&quot; &lt;?php comment_class(); ?&gt;&gt;
			&lt;div id=&quot;comment-&lt;?php comment_ID(); ?&gt;&quot; class=&quot;the-comment&quot;&gt;
			&lt;div class=&quot;comment-author vcard&quot;&gt;
				&lt;?php echo get_avatar($comment,$size='36',$default='&lt;path_to_url&gt;' ); ?&gt;
				&lt;?php printf(__('&lt;cite class=&quot;fn&quot;&gt;%s&lt;/cite&gt; &lt;span class=&quot;says&quot;&gt;says:&lt;/span&gt;'), get_comment_author_link()) ?&gt;
			&lt;/div&gt;

	&lt;?php if ($comment-&gt;comment_approved == '0') : ?&gt;
		&lt;em&gt;&lt;?php _e('Your comment is awaiting moderation.') ?&gt;&lt;/em&gt;
		&lt;br /&gt;
	&lt;?php endif; ?&gt;

	&lt;div class=&quot;comment-meta commentmetadata&quot;&gt;
		&lt;a href=&quot;&lt;?php echo htmlspecialchars(get_comment_link( $comment-&gt;comment_ID )) ?&gt;&quot;&gt;
		&lt;?php printf(__('%1$s at %2$s'), get_comment_date(),get_comment_time()) ?&gt;&lt;/a&gt;&lt;?php edit_comment_link( __( '(Edit)' ), ' ' ); ?&gt;
	&lt;/div&gt;

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

	&lt;?php if($args['max_depth']!=$depth) { ?&gt;
		&lt;div class=&quot;reply&quot;&gt;
			&lt;?php comment_reply_link(array_merge($args, array('depth' =&gt; $depth, 'max_depth' =&gt; $args['max_depth']))) ?&gt;
		&lt;/div&gt;
	&lt;?php } ?&gt;
	&lt;/div&gt;</pre>
<p>Edit the HTML to your liking. Do not close the li at the end, as WordPress does this for you to accommodate nested list elements for threaded comments, etc.</p>
<p><strong>To display your custom callback</strong>, open your theme&#8217;s <em>comments.php</em> file and change <em>wp_list_comments()</em> to use the callback:</p>
<pre class="brush: php; title: comments.php; toolbar: false; notranslate">&lt;ol class=&quot;commentlist&quot;&gt;
	&lt;!-- Utilizes a callback to enable customization of comment HTML - see functions.php --&gt;
	&lt;?php wp_list_comments('callback=cc_callback'); ?&gt;
&lt;/ol&gt;</pre>
<h2>Custom Login Logo and Link</h2>
<p>This snippet will replace the WordPress login page&#8217;s logo with an image you upload to your theme&#8217;s <em>/images</em> folder. Keep in mind that the default available dimensions are 326px x 57px, so you will want your logo to be within this size.</p>
<pre class="brush: php; title: functions.php - Custom Login Logo; toolbar: false; notranslate">// custom admin login logo
function custom_login_logo() {
	echo '&lt;style type=&quot;text/css&quot;&gt;
		html .login h1 a { background-image: url('.get_template_directory_uri().'/images/custom-login-logo.png); }
	&lt;/style&gt;';
}
add_action('login_head', 'custom_login_logo');</pre>
<p>Now, the logo will be custom but it&#8217;s still linking to <a href="http://www.wordpress.org">wordpress.org</a>. If you&#8217;d like to change the URL so that clicking the logo takes you to your site&#8217;s homepage, add the following functions:</p>
<pre class="brush: php; title: functions.php - Custom Logo URL; toolbar: false; notranslate">function custom_login_url() {
  return home_url();
}
add_filter( 'login_headerurl', 'custom_login_url', 10, 4 );</pre>
<h2>Custom Post Types and Custom Taxonomies</h2>
<p>One of the other great things you can do with <em>functions.php</em> is add support for custom post types and custom taxonomies. However, this is an entire topic unto itself, and has been covered in two other posts: <a href="http://blog.kim-maida.com/web-development/wordpress/custom-post-types-taxonomies">Custom Post Types &amp; Taxonomies</a> and <a href="http://blog.kim-maida.com/web-development/wordpress/custom-post-types-revisited">Custom Post Types, revisited</a>.</p>
<h2>Final Notes</h2>
<p>You should avoid modifying WordPress&#8217;s core files. The <em>functions.php</em> file should always be used instead. This way, your changes will not affect or compromise the entire installation. When WordPress updates, your changes will not be overwritten.</p>
<p>Browse the web and the <a href="http://codex.wordpress.org">WordPress Codex</a> to find out what else you can do with WordPress functions. The possibilities vastly outstrip anything I could even attempt to cover here.</p>
<p>Happy developing!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kim-maida.com/web-development/wordpress/wordpress-functions-php-file/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 CSS Reset Stylesheet</title>
		<link>http://blog.kim-maida.com/web-development/html5-css-reset-stylesheet</link>
		<comments>http://blog.kim-maida.com/web-development/html5-css-reset-stylesheet#comments</comments>
		<pubDate>Wed, 04 Jan 2012 18:55:17 +0000</pubDate>
		<dc:creator>Kim</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://blog.kim-maida.com/?p=653</guid>
		<description><![CDATA[My newly-updated reset stylesheet with a few omissions, additions, and edits. Please feel free to use and edit this CSS reset as you see fit.]]></description>
			<content:encoded><![CDATA[<p>My newly-updated reset stylesheet with a few omissions, additions, and edits. Please feel free to use and edit this CSS reset as you see fit.</p>
<pre class="brush: css; title: HTML5 CSS Reset; toolbar: false; notranslate">/*--------------------
      CSS RESET
--------------------*/

/*
HTML5 Reset
Version 1.1
Author: Kim Maida | http://kim-maida.com
Updated: 1-4-2012
*/

html, body, div, span, h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins,
kbd, q, s, samp, small, strike, strong, tt, var, dl, dt,
dd, ol, ul, li, fieldset, form, input, textarea, label, legend, table, caption,
tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
	margin: 0; padding: 0;
	border: 0; outline: 0;
    font-weight: inherit; font-style: inherit; font-family: inherit;
	line-height: 1;
	text-decoration: none;
	vertical-align: baseline;
}

img, input, select { vertical-align: middle; }

ol, ul { list-style: none; }

a,
label,
input[type=button],
input[type=submit],
button { cursor: pointer; }

input, select, textarea { font-family: inherit; }
textarea { overflow: auto; } /* prevents scrollbar from showing up when unneeded in IE */

table {
	border-collapse: collapse;
	border-spacing: 0;
}

caption, th, td { text-align: left; font-weight: normal; }

h1, h2, h3, h4, h5, h6 { font-weight: normal; }

i, em { font-style: italic; }
b, strong { font-weight: bold; }

q:lang(en) { quotes: '&amp;#8220;' '&amp;#8221;' '&amp;#8216;' '&amp;#8217;'; }

article, aside, canvas, details, figcaption, figure,
footer, header, hgroup, menu, nav, section { display: block; }

del { text-decoration: line-through; }

abbr[title], dfn[title] {
	border-bottom: 1px dotted;
	cursor: help;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.kim-maida.com/web-development/html5-css-reset-stylesheet/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress No Post Title</title>
		<link>http://blog.kim-maida.com/web-development/wordpress/wordpress-no-post-title</link>
		<comments>http://blog.kim-maida.com/web-development/wordpress/wordpress-no-post-title#comments</comments>
		<pubDate>Tue, 03 Jan 2012 16:39:04 +0000</pubDate>
		<dc:creator>Kim</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[quick tips]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[themes]]></category>

		<guid isPermaLink="false">http://blog.kim-maida.com/?p=624</guid>
		<description><![CDATA[When a WordPress post has no title, it is beneficial to provide fallback text that will print to still provide a link to the post.

Place the provided code in between the title permalink anchor tags in your loop to generate "Untitled Post" text for any post where the user has not entered a title. Edit the code as appropriate for your needs.]]></description>
			<content:encoded><![CDATA[<p>When a WordPress post has no title, it is beneficial to provide fallback text that will print to still provide a link to the post.</p>
<p>Place the following code in between the title permalink anchor tags in your loop to generate &#8220;Untitled Post&#8221; text for any post where the user has not entered a title:</p>
<pre class="brush: php; title: ; toolbar: false; notranslate">&lt;?php
	$title = get_the_title();
	if (strlen($title) == 0) echo 'Untitled Post';
	else echo $title;
?&gt;</pre>
<p>Edit the snippet appropriately for your needs.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kim-maida.com/web-development/wordpress/wordpress-no-post-title/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress HTML5 Blank Theme</title>
		<link>http://blog.kim-maida.com/web-development/wordpress/wordpress-html5-theme</link>
		<comments>http://blog.kim-maida.com/web-development/wordpress/wordpress-html5-theme#comments</comments>
		<pubDate>Sat, 31 Dec 2011 15:36:48 +0000</pubDate>
		<dc:creator>Kim</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[FREE]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[themes]]></category>

		<guid isPermaLink="false">http://blog.kim-maida.com/?p=390</guid>
		<description><![CDATA[Download a bare-bones WordPress theme, ready for customization and styling. WordPress's native themes are feature-rich but can be tedious and exhausting to customize out of the box. Likewise, creating themes repeatedly from the ground-up can also be an arduous task. 

This template HTML5 theme contains popular features such as post thumbnails, threaded comments, menus, jQuery, and more, but with minimal styling. The template was built to be a platform for custom development and is fully ready for to be repurposed and expanded for your theme-making needs.]]></description>
			<content:encoded><![CDATA[<p>This theme utilizes advanced CSS selectors as well as select classes as styling selectors. You should, of course, add whatever HTML and CSS you like to customize the theme to your needs.</p>
<h2>Features</h2>
<p>The theme natively contains support for the following features and improvements:</p>
<ul>
<li>HTML5 with shim for unsupported browsers</li>
<li>Conditional classes for IE7/8</li>
<li>Threaded comments with custom callback</li>
<li>Featured Images / Post Thumbnails</li>
<li>Editor styles</li>
<li>Dynamic sidebar</li>
<li>Menus</li>
<li>Widgets</li>
<li>jQuery</li>
<li>Smart caching of <em>style.css</em> and <em>script.js</em></li>
<li>Responsive CSS design for mobile / smaller browser viewports</li>
<li>Uses <em>get_template_part</em> for includes to improve ease of modification</li>
</ul>
<h2>Demo / Preview</h2>
<p>You may preview a demo of this theme at <a href="http://demo.kim-maida.com/wordpress">Demo KM WordPress</a>.</p>
<h2>Custom Post Types &amp; Taxonomies</h2>
<p>If you plan on adding custom post types, custom taxonomies, and/or custom meta boxes and custom fields to your theme, the <a href="http://blog.kim-maida.com/web-development/wordpress/custom-post-types-taxonomies">KM Custom Post Type Template</a> plugin and theme files are intended to integrate well with the bare-bones KM-H5 theme. (You will need to remove the featured images functions from the plugin, however, as these functions are duplicated in the theme&#8217;s <em>functions.php</em> file.) Keep in mind that these are <em>learning</em> files: their intent is to teach.</p>
<p>If you&#8217;d prefer an efficiency-based method to get to the end results, try <a href="http://blog.kim-maida.com/web-development/wordpress/custom-post-types-revisited">Custom Post Types, revisited</a> for another way of adding custom CMS functionality to your WordPress installation. This technique is geared toward more real-world production, but leaves out much of the teaching.</p>
<h2>Regular Updates</h2>
<p>Keep an eye on the blog for improvements! Updates and fixes for the theme will be added when appropriate as new versions of WordPress are released, introducing new features and functionality.</p>
<h3>Changelog</h3>
<ul>
<li><em>Feb. 18, 2012</em> &#8211; Updated functions.php to call jQuery from Google&#8217;s CDN and to remove the WP version number from the head for better security. Minor CSS change to accommodate next/prev links for posts with excessively long titles.</li>
<li><em>Feb. 17, 2012</em> &#8211; Added pagination links template part to the loop (Prev/Next with page numbers). Please note that depending on your installation&#8217;s permalink / pagination settings, you may have to edit the format. See the documentation: <a href="http://codex.wordpress.org/Function_Reference/paginate_links">paginate_links</a>.</li>
<li><em>Jan. 7, 2012</em> &#8211; Added international translation support.</li>
<li><em>Jan. 5, 2012</em> &#8211; Fixed a misplaced end tag in the comments template, broke commonly-repeated elements into template parts (includes), various other small improvements.</li>
<li><em>Jan. 4, 2012</em> &#8211; Numerous fixes for styling, structure, and classes. Removed post format support (determined unnecessary and rarely used). Added CSS3 media query for responsive design. Did some major clean-up and added cache-busting for js and main stylesheet without the use of functions.php.</li>
<li><em>Jan. 3, 2012</em> &#8211; v1.3 released with support for untitled posts, post formats, enhanced styling, and other minor fixes</li>
<li><em>Dec. 31, 2011</em> &#8211; Added intelligent caching of stylesheet, removed version from footer for better security, fixed author page query, added demo</li>
<li><em>Dec. 15, 2011</em> &#8211; Fixed editor styles</li>
<li><em>Dec. 6, 2011</em> &#8211; Added author support</li>
</ul>
<h3>Questions? Feature requests?</h3>
<p>Leave a comment!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kim-maida.com/web-development/wordpress/wordpress-html5-theme/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WordPress CSS and JS Caching</title>
		<link>http://blog.kim-maida.com/web-development/wordpress/wordpress-css-and-js-caching</link>
		<comments>http://blog.kim-maida.com/web-development/wordpress/wordpress-css-and-js-caching#comments</comments>
		<pubDate>Fri, 30 Dec 2011 21:19:37 +0000</pubDate>
		<dc:creator>Kim</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[quick tips]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://blog.kim-maida.com/?p=600</guid>
		<description><![CDATA[If you are working on developing a WordPress theme and you find yourself making numerous, rapid stylesheet or JavaScript changes but are frustrated when theupdates don't show up on the web no matter how many times you force-refresh and empty your browser's history, you've got cached files. Caching is a good thing, but when you want to see your changes, it can become a hindrance very quickly. This post addresses busting the cache when a file has been updated.]]></description>
			<content:encoded><![CDATA[<p>If you are working on developing a WordPress theme and you find yourself making numerous, rapid stylesheet or JavaScript changes but are frustrated when theupdates don&#8217;t show up on the web no matter how many times you force-refresh and empty your browser&#8217;s history, you&#8217;ve got cached files. Caching is a good thing, but when you want to see your changes, it can become a hindrance very quickly. This post addresses busting the cache when a file has been updated.</p>
<p>The solution is to intelligently cache stylesheets when they haven&#8217;t changed, but to reload them when they&#8217;ve been updated utilizing the PHP file modification time function <a href="http://php.net/manual/en/function.filemtime.php">filemtime()</a>. Some CMSes do this natively (like </a><a href="http://www.expressionengine.com">Expression Engine</a>), but WordPress doesn&#8217;t— yet.</a></p>
<p>You can add this functionality to your theme by modifying the stylesheet link in the <strong>header.php</strong> theme file as follows:</p>
<pre class="brush: plain; title: header.php; toolbar: false; notranslate">&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;&lt;?php bloginfo('stylesheet_url'); echo '?' . filemtime( get_stylesheet_directory() . '/style.css'); ?&gt;&quot; media=&quot;screen&quot;&gt;</pre>
<p>If you have additional stylesheets or JavaScript files you&#8217;d like to apply <em>filemtime()</em> to as well, use the following syntax:</p>
<pre class="brush: php; title: CSS or JavaScript Files; toolbar: false; notranslate">&lt;?php $cachebustFile = '/your-subdirectory/your-file.ext'; ?&gt;
&lt;script src=&quot;&lt;?php echo get_template_directory_uri(); echo $cachebustFile . '?' . filemtime(get_template_directory() . $cachebustFile); ?&gt;&quot;&gt;&lt;/script&gt;</pre>
<p>For more information, see <a href="http://wordpress.stackexchange.com/questions/5116/cache-busting-css-files-other-than-style-css">Cache busting CSS files other than style.css</a>, <a href="http://css-tricks.com/snippets/wordpress/prevent-css-caching/">Prevent CSS Caching</a>, or <a href="http://www.alistercameron.com/2008/09/10/smart-cache-busting-for-your-wordpress-stylesheet/">Smart Cache-busting for your WordPress Stylesheet</a>.</p>
<p><strong>Note:</strong> If you have downloaded my <a href="http://blog.kim-maida.com/web-development/wordpress/wordpress-html5-theme">KM-H5 template theme</a> after Dec. 31, 2011, this feature is already included in the core theme files.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kim-maida.com/web-development/wordpress/wordpress-css-and-js-caching/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Post Types, revisited</title>
		<link>http://blog.kim-maida.com/web-development/wordpress/custom-post-types-revisited</link>
		<comments>http://blog.kim-maida.com/web-development/wordpress/custom-post-types-revisited#comments</comments>
		<pubDate>Mon, 12 Dec 2011 19:20:14 +0000</pubDate>
		<dc:creator>Kim</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[custom post types]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.kim-maida.com/?p=479</guid>
		<description><![CDATA[A couple of months ago, I did a <a href="http://blog.kim-maida.com/web-development/wordpress/custom-post-types-taxonomies">comprehensive overview on how to set up custom post types, taxonomies, and custom meta boxes</a> in your WordPress installation. Now I will revisit custom post types and taxonomies, except this time we will use <em>efficiency</em> rather than learning as our guiding principle and go over the quickest way to set up customization of post types for WordPress.]]></description>
			<content:encoded><![CDATA[<p>This time we will be relying on other plugins to generate custom meta boxes, so all we need to worry about is setting up the taxonomies and custom posts. You may follow along with the tutorial to write your own code, or download the above plugin and edit it as appropriate.</p>
<p><strong>Plugin or functions.php?</strong> The advantage to using a plugin for Custom Post Types is that plugins will persist if you elect to change your theme. <em>functions.php</em> files are tied to their themes. This isn&#8217;t a fool-proof catch-all, as Custom Post Types and taxonomies require certain theme files in order to display, but it will eliminate the need to remember to copy over a significant portion of your theme&#8217;s functions if you use a plugin. Using a plugin also allows you to deactivate the CPTs if desired. Ultimately though, the choice is yours.</p>
<p>If you&#8217;re writing a plugin to handle your custom posts rather than putting them in your theme&#8217;s <em>functions.php</em> file, you need to begin your PHP file with some general plugin information. (Skip this step if you&#8217;re using <em>functions.php</em>.)</p>
<pre class="brush: php; title: Begin the plugin; toolbar: false; notranslate">&lt;?php
/**
 * @package Setup_Custom_Post
 * @version 1.0
 */
/*
Plugin Name: Setup Custom Post Type
Plugin URI: http://blog.kim-maida.com/web-development/wordpress/custom-post-types-revisited
Description: A sample &quot;template&quot; custom post type plugin for editing. 

Author: Kim Maida
Version: 1.0
Author URI: http://kim-maida.com
License: Free
*/</pre>
<p>We&#8217;ll start by <strong>setting up the filter to enable our custom post type to share categories and post tags with standard posts</strong>. Leave this off if you do not want this functionality.</p>
<pre class="brush: php; title: Add tag and category support; toolbar: false; notranslate">
// Filter to enable custom post types to share categories and tags with regular posts
//--- Remove this section if your custom post will not be sharing any categories or tags
//--- May require further editing if you will be adding additional custom post types

add_filter('pre_get_posts', 'query_post_type');
function query_post_type($query) {
	if(is_category() || is_tag()) {
		$post_type = get_query_var('post_type');
	if($post_type)
		$post_type = $post_type;
	else
		$post_type = array(
			'post',
			'custom_post'	 // add custom post type(s) here
		);
	$query-&gt;set('post_type',$post_type);
	return $query;
	}
}
</pre>
<p><strong>Set up the custom taxonomies</strong> next. The reason we are doing this before initializing the new custom post type is because we want to rewrite the taxonomy slugs to attach them to the custom post type slug. What this means is that taxonomy archives will be rewritten to the format of: <em>URL/custom-post-type/taxonomy/term</em>, instead of: <em>URL/taxonomy/term</em>.</p>
<p>You will want to leave this particular rewrite functionality off if you are sharing custom taxonomies among multiple post types.</p>
<p>Here is some code registering a hierarchical (category-like, with parent/child structure) taxonomy:</p>
<pre class="brush: php; title: Create a Hierarchical Taxonomy; toolbar: false; notranslate">//-------------------------- CUSTOM TAXONOMIES
//-------------------------- http://codex.wordpress.org/Taxonomies#Custom_Taxonomies

add_action( 'init', 'create_hierarchical_taxonomy', 0 );
function create_hierarchical_taxonomy()
{
	// The labels that your custom taxonomy will use in the WordPress admin UI
    $labels = array(
    	'name' =&gt; _x( 'Hierarchical Taxonomy', 'taxonomy general name' ),
		'singular_label' =&gt; _x( 'Hierarchical Taxonomy', 'taxonomy singular name' ),
		'search_items' =&gt; __( 'Search Hierarchical Taxonomies' ),
		'all_items' =&gt; __( 'All Hierarchical Taxonomies' ),
		'parent_item' =&gt; __( 'Parent Hierarchical Taxonomy' ),
		'parent_item_colon' =&gt; __( 'Hierarchical Taxonomy' ),
		'edit_item' =&gt; __( 'Edit Hierarchical Taxonomy' ),
		'update_item' =&gt; __( 'Update Hierarchical Taxonomy' ),
		'add_new_item' =&gt; __( 'Add New Hierarchical Taxonomy' ),
		'new_item_name' =&gt; __( 'New Hierarchical Taxonomy Name' )
    );

    // http://codex.wordpress.org/Function_Reference/register_taxonomy
	register_taxonomy(
		'h_taxonomy', // internal name
		'custom_post', // object type - what post type can use this taxonomy, can also be an array of post types: array( 'post', 'page')
		array(
			// http://codex.wordpress.org/Function_Reference/register_taxonomy#Arguments
			'labels' =&gt; $labels,	// Instructs use of the labels specified above
			'hierarchical' =&gt; true, // True: tree-structure like categories
			'rewrite' =&gt; array( 'slug' =&gt; 'custom-post/hierarchical-taxonomy', 'with_front' =&gt; false),	// Applies a rewrite associating this taxonomy with the specified CPT
			'query_var' =&gt; true
		)
	);
}</pre>
<p>Here is sample code for registering a non-hierarchical (free-form, like tags) taxonomy:</p>
<pre class="brush: php; title: Create a Non-hierarchical Taxonomy; toolbar: false; notranslate">add_action( 'init', 'create_nh_taxonomy', 0 );
function create_nh_taxonomy()
{
	// The labels that your custom taxonomy will use in the WordPress admin UI
    $labels = array(
    	'name' =&gt; _x( 'Non-hierarchical Taxonomy', 'taxonomy general name' ),
		'singular_label' =&gt; _x( 'Non-hierarchical Taxonomy', 'taxonomy singular name' ),
		'search_items' =&gt; __( 'Search Non-hierarchical Taxonomies' ),
		'all_items' =&gt; __( 'All Non-hierarchical Taxonomies' ),
		'parent_item' =&gt; __( 'Parent Non-hierarchical Taxonomy' ),
		'parent_item_colon' =&gt; __( 'Parent Non-hierarchical Taxonomy' ),
		'edit_item' =&gt; __( 'Edit Non-hierarchical Taxonomy' ),
		'update_item' =&gt; __( 'Update Non-hierarchical Taxonomy' ),
		'add_new_item' =&gt; __( 'Add New Non-hierarchical Taxonomy' ),
		'new_item_name' =&gt; __( 'New Non-hierarchical Taxonomy Name' ),
		'separate_items_with_commas' =&gt; __( 'Separate Non-hierarchical Taxonomies with commas' ),
		'choose_from_most_used' =&gt; __( 'Choose from most used Non-hierarchical Taxonomies' )
    );

    // http://codex.wordpress.org/Function_Reference/register_taxonomy
	register_taxonomy(
		'nh_taxonomy', // internal name
		'custom_post', // object type - what post type can use this taxonomy, can also be an array of post types: array( 'post', 'page')
		array(
			// http://codex.wordpress.org/Function_Reference/register_taxonomy#Arguments
			'labels' =&gt; $labels,	// Instructs use of the labels specified above
			'hierarchical' =&gt; false, // False: free-form structure like tags
			'rewrite' =&gt; array( 'slug' =&gt; 'custom-post/nonhierarchical-taxonomy', 'with_front' =&gt; false), // Applies a rewrite associating this taxonomy with the specified CPT
			'query_var' =&gt; true
		)
	);
}</pre>
<p>Next, <strong>register the custom post type</strong>. Note that the <em>rewrite</em> slug for the CPT should match the slug you specified to come before your associated custom taxonomies. (Ie: if the taxonomy rewrite was <em>cpt-slug/taxonomy</em>, the CPT rewrite slug needs to be <em>cpt-slug</em>.)</p>
<pre class="brush: php; title: Custom Post Type; toolbar: false; notranslate">//-------------------------- CUSTOM POST TYPE
//-------------------------- http://codex.wordpress.org/Post_Types#Custom_Types

add_action('init', 'create_custom_post');
function create_custom_post()
{
	// The labels your custom post type will use in the WordPress admin UI
	$labels = array(
		'name' =&gt; _x( 'Custom Post', 'custom post' ),
		'singular_name' =&gt; _x( 'Custom Post', 'custom post' ),
		'all_items' =&gt; __( 'All Custom Posts' ),
		'add_new' =&gt; __( 'Add New Custom Post' ),
		'add_new_item' =&gt; __( 'Add New Custom Post' ),
		'edit_item' =&gt; __( 'Edit Custom Post' ),
		'menu_name' =&gt; _x( 'Custom Posts', 'custom posts' ),
	); 

	// http://codex.wordpress.org/Function_Reference/register_post_type#Arguments
	$args = array(
		'labels' =&gt; $labels,	// Instructs use of the labels specified above
		'description' =&gt; _x( 'A default custom post type for customizing.', 'Short descriptive summary of the post type' ),
		'public' =&gt; true, 	// Meta argument to define default values for publicly_queriable, show_ui, show_in_nav_menus, exclude_from_search
		'menu_position' =&gt; 5,	// 5 = Below posts (see WP codex for more information on menu position)
		'hierarchical' =&gt; false,	// True: parent structure like pages | False: like posts
		'supports' =&gt; array('title', 'editor', 'thumbnail', 'excerpt', 'revisions', 'author', 'discussion', 'comments'),	// Alias for add_post_type_support()
		'taxonomies' =&gt; array('category','post_tag'), // Shares these with other posts: needs a query function for archives to work!
		'has_archive' =&gt; __('custom-posts'),	// Enables custom post type archives: boolean or string (string will be the archive slug)
		'rewrite' =&gt; array('slug' =&gt; 'custom-post', 'with_front' =&gt; false )	// Rewrite permalinks, create a slug for the custom post type
	);    

	// http://codex.wordpress.org/Function_Reference/register_post_type
	register_post_type(
		'custom_post',	// internal name
		$args 	// arguments from the array above
	);
}</pre>
<p>We should <strong>flush rewrite on activation</strong> to prevent 404 errors. If you continue to have 404s on archive pages, etc., visit the Permalink settings and re-save. (Also noted below.)</p>
<pre class="brush: php; title: Flush Rewrite; toolbar: false; notranslate">// Flush rewrite on activation: this should prevent 404 errors when trying to view custom posts and archives
add_action('init', 'create_custom_post');
function my_rewrite_flush() {
	create_custom_post();
	flush_rewrite_rules();
}
register_activation_hook(__FILE__, 'my_rewrite_flush');</pre>
<p>Finally, if you&#8217;re putting this code in a <em>plugin</em> instead of your theme&#8217;s <em>functions.php</em>, end the plugin:</p>
<pre class="brush: php; title: End the plugin; toolbar: false; notranslate">// end the plugin ?&gt;</pre>
<p>Now that we have taxonomies and custom post types set up, we can <strong>create custom fieldgroups</strong> to use. This can be done by hand by constructing custom meta boxes, as previously covered in a different post, but <em>the fastest and easiest way to do this is to use a robust custom fields plugin</em>. I recommend <a href="http://wordpress.org/extend/plugins/advanced-custom-fields/">Advanced Custom Fields</a>. This plugin allows you to associate fieldgroups with different post types. It supports a variety of field types, file uploads, etc. and also uses short tags to get and display the custom field data. Visit the <a href="http://plugins.elliotcondon.com/advanced-custom-fields/documentation/">Advanced Custom Fields developer&#8217;s website</a> for full documentation.</p>
<p>See the <a href="http://blog.kim-maida.com/tag/custom-post-types">custom post types</a> archives for additional articles on how to set up and use custom post types in WordPress.</p>
<p><strong>Getting 404 errors on custom taxonomy archives?</strong> Before you tear your hair out unable to figure out where you went wrong in the code, try visiting your admin section&#8217;s <em>Settings</em> / <em>Permalinks</em> and hit &#8220;Save Changes&#8221; to flush the cache. This should fix those confounding Not Founds. If they persist after doing this, <em>then</em> check the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kim-maida.com/web-development/wordpress/custom-post-types-revisited/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Querying Multiple Post Types</title>
		<link>http://blog.kim-maida.com/web-development/wordpress/querying-multiple-post-types</link>
		<comments>http://blog.kim-maida.com/web-development/wordpress/querying-multiple-post-types#comments</comments>
		<pubDate>Mon, 12 Dec 2011 17:21:11 +0000</pubDate>
		<dc:creator>Kim</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[custom post types]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[quick tips]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://blog.kim-maida.com/?p=460</guid>
		<description><![CDATA[When using multiple post types (such as standard posts mixed with custom posts), it may become necessary to query several types at once. Note that whenever you query posts, you need to ensure that pagination is enabled as well. You may do so by using this code.]]></description>
			<content:encoded><![CDATA[<p>When using multiple post types (such as standard posts mixed with custom posts), it may become necessary to query several types at once. Note that whenever you query posts, you need to ensure that pagination is enabled as well. You may do so by using the following code:</p>
<pre class="brush: php; title: Querying multiple post types; toolbar: false; notranslate">&lt;?php
    // enable pagination using the $paged variable
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

    // query posts
	query_posts(array(
		'post_type' =&gt; array(
			'post',
			'custom_post_type',
			'another_custom_post_type'
		),
		'paged' =&gt; $paged )
	);
?&gt;</pre>
<p>Replace the custom post types in the <a href="http://codex.wordpress.org/Function_Reference/query_posts">query_posts</a> array with your own.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kim-maida.com/web-development/wordpress/querying-multiple-post-types/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Object Caching 629/764 objects using disk: basic

Served from: blog.kim-maida.com @ 2012-05-20 18:49:42 -->
