<?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; header</title>
	<atom:link href="http://digwp.com/tag/header/feed/" rel="self" type="application/rss+xml" />
	<link>http://digwp.com</link>
	<description>Take your WordPress skills to the next level.</description>
	<lastBuildDate>Fri, 18 May 2012 18:21:22 +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>Custom CSS Per Post</title>
		<link>http://digwp.com/2010/02/custom-css-per-post/</link>
		<comments>http://digwp.com/2010/02/custom-css-per-post/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 20:17:20 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[header]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1221</guid>
		<description><![CDATA[I&#8217;ve long been a fan of &#8220;art directing&#8221; posts. That is, to apply unique CSS styling to an individual page of content when the situation calls for it. In the past, I&#8217;ve used the Art Direction plugin and I even created a screencast on using it. As it turns out, there is a major problem [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve long been a fan of &#8220;art directing&#8221; posts. That is, to apply unique CSS styling to an individual page of content when the situation calls for it. In the past, I&#8217;ve used the <a href="http://wordpress.org/extend/plugins/art-direction/">Art Direction plugin</a> and I even <a href="http://css-tricks.com/video-screencasts/77-styling-an-individual-article/">created a screencast</a> on using it. </p>
<p>As it turns out, there is a <strong>major problem</strong> with the art direction plugin. Using it with <em>any caching plugin</em> will result in a crazy epic meltdown of your site. Without too much gory detail, in trying to cache my blog <a href="http://css-tricks.com">CSS-Tricks</a>, I tried all the major caching plugins (DB Cache, WP Super Cache, W3 Total Cache) and ultimately it would trash my WordPress database and serve up white pages. Very not good. The happy ending is that Frederick Townes from <a href="http://www.w3-edge.com/">W3 Edge</a> and creator of the W3 Total Cache plugin helped me out by patching the art direction plugin and getting CSS-Tricks cached with <a href="http://wordpress.org/extend/plugins/w3-total-cache/">W3 Total Cache</a>. I would love to release the updated code, but it&#8217;s not my code to release. We managed to get in touch with the <a href="http://noel.io/">original author</a>, who said he planed to eventually update it but didn&#8217;t sound too particularly interested in the patch.</p>
<p>SO, with that extensive backstory, what is a poor fellow to do if they want to apply custom CSS to pages TODAY? Couple ideas, read on.</p>
<p><span id="more-1221"></span></p>
<h3>style-XXXX.css</h3>
<p>One of my <a href="http://digwp.com/2010/01/wordpress-wishes/">&#8220;WordPress Wishes&#8221;</a> was that you could drop an appropriately named CSS file into a theme and it would recognize it and apply itself to the proper post. For example, /art-direction/style-XXXX.css, where XXXX is the ID of the post.</p>
<p>Reader <a href="http://tween.ir/blog/">Hassan</a> <a href="http://digwp.com/2010/01/wordpress-wishes/#comment-3072">commented</a> with a cool idea for the functions.php file:</p>
<pre><code>function artStyle() {
    global $post;
    if (is_single()) {
        $currentID = $post-&gt;ID;
        $serverfilepath = TEMPLATEPATH.'/art-direction/style-'.$currentID.'.css';
        $publicfilepath = get_bloginfo('template_url');
        $publicfilepath .= '/art-direction/style-'.$currentID.'.css';
        if (file_exists($serverfilepath)) {
            echo "&lt;link rel='stylesheet' type='text/css' href='$publicfilepath' media='screen' /&gt;"."\n";
        }
    }
}
add_action('wp_head', 'artStyle');</code></pre>
<p>I tested it out and it works great. To use it, simply create a new folder called &#8220;art-direction&#8221; in your theme. Then to style any particular Post or Page, just drop a file in that folder named style-XXXX.css where XXXX is the ID of the Post or Page. When that Post or Page loads, WordPress will look for a file of that name. If it exists, it will load in in the head section. </p>
<h3>Custom Panel</h3>
<p>Reader <a href="http://www.kerricklong.com/">Kerrick Long</a> <a href="http://digwp.com/2010/01/wordpress-wishes/#comment-3035">commented</a> another cool solution. Similar to the Art Direction plugin, this adds an input area below the main content writing area. For the functions.php file:</p>
<pre><code>//Custom CSS Widget
add_action('admin_menu', 'custom_css_hooks');
add_action('save_post', 'save_custom_css');
add_action('wp_head','insert_custom_css');
function custom_css_hooks() {
	add_meta_box('custom_css', 'Custom CSS', 'custom_css_input', 'post', 'normal', 'high');
	add_meta_box('custom_css', 'Custom CSS', 'custom_css_input', 'page', 'normal', 'high');
}
function 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;textarea name="custom_css" id="custom_css" rows="5" cols="30" style="width:100%;"&gt;'.get_post_meta($post-&gt;ID,'_custom_css',true).'&lt;/textarea&gt;';
}
function 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 insert_custom_css() {
	if (is_page() || is_single()) {
		if (have_posts()) : while (have_posts()) : the_post();
			echo '&lt;style type="text/css"&gt;'.get_post_meta(get_the_ID(), '_custom_css', true).'&lt;/style&gt;';
		endwhile; endif;
		rewind_posts();
	}
}</code></pre>
<div class="image-wrap">
<img src="http://digwp.com/wp-content/blog-images/csspanel.png" width="368" height="236" alt="" title="" /><br />
Custom CSS Write Panel
</div>
<p>As written, it&#8217;s more limiting than the Art Direction plugin as it is for CSS only rather than &#8220;anything&#8221; (e.g. JavaScript), although that would be a fairly trivial adjustment to what gets echoed out. The Art Direction plugin also allowed the CSS to be applied in other places the post might be output, for example, archives pages, whereas this does not. But to be honest, I never used that anyway.</p>
<h3>And so&#8230;</h3>
<p>Two pretty sweet and totally function solutions by Digging Into WordPress readers. Awesome. Huge thanks to Hassan and Kerrick! I would also love to see the Art Direction plugin updated as well, if nothing else, because I&#8217;m sure people download that plugin every single day from the plugin repository and have caching going on their blogs and end up in the same sore spot I was.</p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/02/custom-css-per-post/">Permalink</a> | <a href="http://digwp.com/2010/02/custom-css-per-post/#comments">29 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/02/custom-css-per-post/&title=Custom CSS Per Post">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/css/" rel="tag">CSS</a>, <a href="http://digwp.com/tag/design/" rel="tag">Design</a>, <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/header/" rel="tag">header</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/02/custom-css-per-post/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>How to Remove the WordPress Version Number (The Right Way)</title>
		<link>http://digwp.com/2009/07/remove-wordpress-version-number/</link>
		<comments>http://digwp.com/2009/07/remove-wordpress-version-number/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 07:01:13 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://diggingintowordpress.com/?p=314</guid>
		<description><![CDATA[One of the most commonly seen security tips around the WordPress-o-Sphere has got to be this: Don’t display your WordPress version number publicly Many WordPress developers often display the WordPress version in the source code. But having this information publicly available makes it easy for attackers to exploit known vulnerabilities on a particular WordPress version. [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most commonly seen security tips around the WordPress-o-Sphere has got to be this:</p>
<blockquote><p><strong><em>Don’t display your WordPress version number publicly</em></strong><br />
<em>Many WordPress developers often display the WordPress version in the source code. But having this information publicly available makes it easy for attackers to exploit known vulnerabilities on a particular WordPress version.</em></p></blockquote>
<p>This sort of thinking is referred to as &ldquo;security through obscurity,&rdquo; and may or may not be an effective way to increase the overall security of your site. </p>
<p><span id="more-314"></span></p>
<p>By default, WordPress executes the <code>wp_generator()</code> function whenever the <code>wp_head()</code> hook is called. Typically, this hook is located in your theme&rsquo;s <code>header.php</code> file within the <code>&lt;head&gt;</code> section of the document markup:</p>
<p><img src="http://digwp.com/wp-content/blog-images/wp-head-screens.gif" alt="[ Screenshot: wp_head() Hook ]" title="The wp_head() hook as seen via the header.php file" /><br /><small>The wp_head() hook as seen via the header.php file</small></p>
<p>Then, after WordPress processes your web page, the <code>wp_generator()</code> function outputs the following code (depending on page view) to your browser:</p>
<pre><code>&lt;link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://digwp.com/xmlrpc.php?rsd" /&gt;
&lt;link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://digwp.com/wp-includes/wlwmanifest.xml" /&gt; 
&lt;link rel='index' title='Digging into WordPress' href='http://digwp.com/' /&gt;
&lt;meta name="generator" content="WordPress 2.8.1" /&gt;</code></pre>
<p>Notice that last line there? There are many posts on WordPress security that point out how specifying your version number is a security risk. Whether or not this is the case is certainly debatable, but the thinking is that you should <em>avoid</em> revealing this sensitive information in order to prevent attacks targeting specific versions of WordPress.</p>
<p>Now for the fun part. Assuming that sharing your version information is bad, how to go about removing the information? Well, that depends on how savvy you are with WordPress. Here are several methods to prevent WordPress from displaying your version-specific number, ranked in order from the absolute <em>worst</em> way to the absolute <em>right</em> way. That is, until someone shows us how to do it in <em>less</em> than 41 characters&nbsp;;)</p>
<h3>The absolute worst way to remove the WordPress version number</h3>
<p>I have seen <em>recent</em> posts where the author actually recommends <em>deleting</em> the <code>wp_head()</code> hook! Here is an example:</p>
<blockquote><p><em>Study what things this function outputs for you, and just hardcode them into your theme files since these values will unlikely change.</em></p></blockquote>
<p>While there are indeed valid reasons for removing this important WordPress hook, removing the version number from your source code is <em>not</em> one of them.</p>
<h3>A pretty good way to remove the WordPress version number</h3>
<p>Much better than simply deleting the <code>wp_head()</code> hook, this method serves us well by placing the version-removal function in the theme&rsquo;s <code>functions.php</code> file, where it belongs. By returning an empty string for <code>the_generator</code> function, this function removes the version information by preventing output of its <code>&lt;meta&gt;</code> tag:</p>
<pre><code>function remove_version_info() {
     return '';
}
add_filter('the_generator', 'remove_version_info');</code></pre>
<p>This method has the added bonus of removing the version information from not only your blog pages, but from your feeds as well.</p>
<h3>The right way to remove the WordPress version number</h3>
<p>Going a step beyond the previous method, this technique gets the job done quite eloquently, with a mere 41 characters of code:</p>
<pre><code>remove_action('wp_head', 'wp_generator');</code></pre>
<p>Just place that single line into your theme&rsquo;s <code>functions.php</code> and enjoy a small taste of &ldquo;security through obscurity&rdquo;.&nbsp;:)</p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/07/remove-wordpress-version-number/">Permalink</a> | <a href="http://digwp.com/2009/07/remove-wordpress-version-number/#comments">30 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2009/07/remove-wordpress-version-number/&title=How to Remove the WordPress Version Number (The Right Way)">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/header/" rel="tag">header</a>, <a href="http://digwp.com/tag/php/" rel="tag">PHP</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/07/remove-wordpress-version-number/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>Use Google-Hosted JavaScript Libraries (&#8230;still the Right Way)</title>
		<link>http://digwp.com/2009/06/use-google-hosted-javascript-libraries-still-the-right-way/</link>
		<comments>http://digwp.com/2009/06/use-google-hosted-javascript-libraries-still-the-right-way/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 21:05:04 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://diggingintowordpress.com/?p=136</guid>
		<description><![CDATA[I previously posted on how to include jQuery in your WordPress theme the Right Way. That is, to use the wp_register_script function to register the script first. It&#8217;s literally a one-liner in your header.php or functions.php file, but by default, it loads the internal version of jQuery that ships with WordPress. It&#8217;s all the rage [...]]]></description>
			<content:encoded><![CDATA[<p>I <a href="http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/">previously posted</a> on how to include jQuery in your WordPress theme the Right Way. That is, to use the <code>wp_register_script</code> function to register the script first. It&#8217;s literally a one-liner in your header.php or functions.php file, but by default, it loads the internal version of jQuery that ships with WordPress. </p>
<p>It&#8217;s all the rage these days (for good reason), to use Google-hosted JavaScript libraries. They even encourage it. If you&#8217;d like to hop on the bandwagon, you can do so and still use the proper <code>wp_register_script</code> function. </p>
<p><span id="more-136"></span></p>
<h3>UPDATE (December 2011)</h3>
<p>As of WordPress 3.3, this is the best way to do it, using the proper hook (thanks David Hollander):</p>
<pre><code>//jQuery Insert From Google
if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
function my_jquery_enqueue() {
   wp_deregister_script('jquery');
   wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false, null);
   wp_enqueue_script('jquery');
}</code></pre>
<p><strike>Just add this code to your <code>functions.php</code> file:</p>
<pre><code>if( !is_admin()){
   wp_deregister_script('jquery'); 
   wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"), false, '1.3.2'); 
   wp_enqueue_script('jquery');
}</code></pre>
<p></strike></p>
<p>That last line there gets the script queued up for you so you don&#8217;t need to do it again in the header. Assuming you have the proper wp_head(); call in your header, you&#8217;ll be all set! Note that we have wrapped this in a <a href="http://codex.wordpress.org/Conditional_Tags">conditional tag</a> to prevent that action on Admin pages. Because this Google-hosted version of jQuery is not in <code>noConflict</code> mode, it interferes with the rich text editor in the admin. This prevents that.</p>
<p>Remember, the reason for all this is to ensure that other WordPress stuff (plugins&#8230;) are aware that the script is already loaded so don&#8217;t go around loading another copy. Loading two copies of a JS library is just bad news.</p>
<p>Also, I always use jQuery as an example but of course this would work with any popular JavaScript library. For example, the MooTools path at Google is:</p>
<pre><code>http://ajax.googleapis.com/ajax/libs/mootools/1.2.2/mootools-yui-compressed.js</code></pre>
<p>Google&#8217;s <a href="http://code.google.com/apis/ajaxlibs/documentation/index.html">AJAX Developer&#8217;s API Guide is here</a>.</p>
<p>ALSO&#8230; there are a crapload of scripts all ready to be queued up for your use in WordPress. See the <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script">full list here</a>. </p>
<p>David wrote in to tell us that he was working in an HTTPS environment, and he used this alteration to ensure the URL for the Google-hosted version of jQuery was properly served from HTTPS when needed:</p>
<pre><code>if (!is_admin()) {
   wp_deregister_script('jquery'); 
   wp_register_script('jquery', ("http".($_SERVER['SERVER_PORT'] == 443 ? "s" : "")."://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"), false, '1.4.2');
   wp_enqueue_script('jquery');
}</code></pre>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/06/use-google-hosted-javascript-libraries-still-the-right-way/">Permalink</a> | <a href="http://digwp.com/2009/06/use-google-hosted-javascript-libraries-still-the-right-way/#comments">22 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2009/06/use-google-hosted-javascript-libraries-still-the-right-way/&title=Use Google-Hosted JavaScript Libraries (&#8230;still the Right Way)">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/header/" rel="tag">header</a>, <a href="http://digwp.com/tag/jquery/" rel="tag">jquery</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/06/use-google-hosted-javascript-libraries-still-the-right-way/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>The xmlrpc.php File and Site Security</title>
		<link>http://digwp.com/2009/06/xmlrpc-php-security/</link>
		<comments>http://digwp.com/2009/06/xmlrpc-php-security/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 14:42:35 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://diggingintowordpress.com/?p=169</guid>
		<description><![CDATA[Located in the header.php file of most WordPress themes, there is an important hook called wp_head(). This essential hook enables functions to output content to the browser in the &#60;head&#62; area of the web document&#160;1. In newer versions of WordPress, this hook enables WordPress to output the following three lines to your theme&#8217;s &#60;head&#62; section&#160;2: [...]]]></description>
			<content:encoded><![CDATA[<p>Located in the <code>header.php</code> file of most WordPress themes, there is an important hook called <code>wp_head()</code>. This essential hook enables functions to output content to the browser in the <code>&lt;head&gt;</code> area of the web document&nbsp;<sup>1</sup>. In newer versions of WordPress, this hook enables WordPress to output the following three lines to your theme&rsquo;s <code>&lt;head&gt;</code> section&nbsp;<sup>2</sup>:</p>
<pre><code>&lt;link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://digwp.com/xmlrpc.php?rsd" /&gt;
&lt;link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://digwp.com/wp-includes/wlwmanifest.xml" /&gt; 
&lt;link rel='index' title='Digging into WordPress' href='http://digwp.com/' /&gt;
&lt;meta name="generator" content="WordPress 2.8" /&gt;</code></pre>
<p>As you can see, lots of stuff is added, including feed links, <acronym title="eXtensible Markup Language - Remote Procedure Call protocol">XML-RPC</acronym> and <acronym title="Windows Live Writer">WLW</acronym> links, and a couple of other items. While there is plenty to discuss with all of these inclusions, here we are concerned primarily with the link to the <code>xmlrpc.php</code> file. WordPress includes this link for its <a href="http://www.xmlrpc.com/" title="XML-RPC Home Page">XML-RPC</a> interface, which enables remote software applications to communicate and interact with WordPress.</p>
<p><span id="more-169"></span></p>
<h3>What does the xmlrpc.php file do? Do I need it?</h3>
<p>While <a href="http://codex.wordpress.org/XML-RPC_Support" title="WordPress Codex: XML-RPC Support">documentation</a> on WordPress&rsquo; <acronym title="eXtensible Markup Language - Remote Procedure Call protocol">XML-RPC</acronym> is fairly thin, we can glean a partial understanding of how the <code>xmlrpc.php</code> works by stepping through the code in the file itself. Don&rsquo;t worry, we&rsquo;re not going to bore you with that here, but suffice it to say that the <code>xmlrpc.php</code> is required for the following types of activity:</p>
<ul>
<li>Posting directly to your blog using TextMate, Flock, and other weblog clients</li>
<li>Posting directly to your blog using Eudora, Thunderbird, and other email apps</li>
<li>Receiving pingbacks and trackbacks to your site from other blogs</li>
</ul>
<p>Not everyone uses the remote-posting functionality available to them in WordPress, but I think that many blogs are definitely using the <acronym title="eXtensible Markup Language - Remote Procedure Call protocol">XML-RPC</acronym> protocol for the pingback and trackback functionality.</p>
<h3>Does the xmlrpc.php file pose a security risk?</h3>
<p>Some of you may remember the <a href="http://xforce.iss.net/xforce/xfdb/33470" title="WordPress xmlrpc.php security bypass">security risk associated with the xmlrpc.php script</a> back in the good &lsquo;ol days of WordPress 2.1.2, whereby:</p>
<blockquote cite="http://xforce.iss.net/xforce/xfdb/33470"><p>WordPress could allow a remote authenticated attacker to bypass security restrictions, caused by improper validation by the xmlrpc.php script. A remote attacker with contributor permissions could exploit this vulnerability to publish posts to the Web site.</p></blockquote>
<p>This vulnerability was promptly eliminated in version 2.1.3, but shortly thereafter (in version 2.3.1) another security issue was discovered when the <a href="http://wordpress.org/development/2007/12/wordpress-232/" title="WordPress 2.3.2 Released">XML-RPC implementation was found to leak information</a>. Although this was fixed in version 2.3.2, the security concerns associated with the <acronym title="eXtensible Markup Language - Remote Procedure Call protocol">XML-RPC</acronym> protocol eventually led the WordPress devs to <a href="http://www.red-sweater.com/blog/512/wordpress-to-disable-remote-access" title="WordPress To Disable Remote Access">disable remote access by default in version 2.6</a>&nbsp;<sup>3</sup>. The <code>xmlrpc.php</code> file is still included in the document <code>&lt;head&gt;</code> (presumably for the sake of pingbacks and trackbacks), but the remote-access functionality is non-operational until explicitly enabled&nbsp;<sup>3</sup>.</p>
<h3>Security tips for your site&rsquo;s xmlrpc.php file</h3>
<p>At the time of this writing, there are no <em>known</em> vulnerabilities associated with WordPress&rsquo; <acronym title="eXtensible Markup Language - Remote Procedure Call protocol">XML-RPC</acronym> protocol. Even so, there have been security issues with the <code>xmlrpc.php</code> script in the past, and there could certainly exist new problems both now and in the future. Just to be on the safe side, here are a few different strategies and tips to help ensure maximum security for your blog.</p>
<p><strong>If you don&rsquo;t need it, delete it</strong><br />Perhaps the safest way to eliminate potential security vulnerabilities is to simply remove the script in question. If you have no need for remote-posting, pingbacks or trackbacks, it may be easiest to simply remove the <code>xmlrpc.php</code> file from your server. Instead of actually deleting it, you may just want to rename it something unguessable. Either way, if the script isn&rsquo;t available to an attacker, it makes it hard to exploit.</p>
<p><strong>Update:</strong> If you remove (or rename) the <code>xmlrpc.php</code> file from your WordPress installation, you should also implement the function described in the next section to avoid an avalanche of 404 errors (see <a href="#comment-254" title="Jump to comment">this comment</a> for further explanation).</p>
<p><strong>Remove the links to xmlrpc.php and wlwmanifest.xml</strong><br />Alternately, if you aren&rsquo;t needing any remote-access or pingback functionality, you may prefer to simply remove the associated header links rather than deleting any core files from your server. This is easily accomplished with the following function placed in your active theme&rsquo;s <code>functions.php</code> file:</p>
<pre><code>function removeHeadLinks() {
	remove_action('wp_head', 'rsd_link');
	remove_action('wp_head', 'wlwmanifest_link');
}
add_action('init', 'removeHeadLinks');</code></pre>
<p>This will prevent these two files from being linked to in the header, but the files themselves will remain available on your server. Definitely make sure that the default disabling of remote publishing in effect if you implement this method.</p>
<p><strong>Disable the remote-publishing functionality</strong><br />If you don&rsquo;t remote-publish, but you still want to receive pingbacks and trackbacks, take WordPress&rsquo; advice and just leave the remote-access functionality disabled by default. This step alone seems like a tremendous way to help tighten down your blog&rsquo;s security. The file will still be available on your server, but attackers will be able to do much less with it.</p>
<p><strong>Prevent malicious xmlrpc.php directory scanning</strong><br />For those of you who wisely keep an eye on your server access and error logs, you have likely seen a recent surge in the amount of malicious <code>xmlrpc.php</code> directory scanning. For whatever reason, the bad guys are suddenly <em>very</em> interested in <code>xmlrpc.php</code> files, and are scanning every directory they can get their bots on trying to locate them. I have seen <em>tons</em> of this kind of activity lately:</p>
<pre><code>http://domain.tld/2009/xmlrpc.php
http://domain.tld/2009/06/xmlrpc.php
http://domain.tld/2009/06/01/xmlrpc.php
http://domain.tld/2009/06/01/permalink/xmlrpc.php
http://domain.tld/2009/06/02/permalink/xmlrpc.php
http://domain.tld/2009/06/03/permalink/xmlrpc.php
.
.
.</code></pre>
<p>Whether the attackers locate their target or not, this kind of behavior drains system resources, hogs bandwidth, and prevents your site from operating at maximum capacity. Thus, to prevent this malicious behavior from damaging your site, I have devised the following <acronym title="Hypertext Access">HTAccess</acronym> solution:</p>
<pre><code>&lt;IfModule mod_alias.c&gt;
RedirectMatch 301 /(.*)/xmlrpc\.php$ http://domain.tld/xmlrpc.php
&lt;/IfModule&gt;</code></pre>
<p>When placed in the web-accessible root <acronym title="Hypertext Access">HTAccess</acronym> file for your site, this simple directive will redirect all requests for your blog&rsquo;s <code>xmlrpc.php</code> file to the actual file. I have been using this method for several weeks now at <a href="http://perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a> and have eliminated thousands of misdirected requests because of it.</p>
<p><strong>Leave the xmlrpc.php file but prevent access to it</strong><br />Last but not least is a simple method enabling you to leave the file in place on your server but prevent access to it. Perfect if you don&rsquo;t need the script and want to be as lazy as possible about keeping it secure (think no maintenance). Simply paste the following code into your root <acronym title="Hypertext Access">HTAccess</acronym> file and be done with it:</p>
<pre><code>&lt;IfModule mod_alias.c&gt;
RedirectMatch 403 /(.*)/xmlrpc\.php$
&lt;/IfModule&gt;</code></pre>
<p><sup>1</sup> Or anywhere the <code>wp_head()</code> hook is located.<br />
<sup>2</sup> Working with WordPress version 2.8 at the time of this writing.<br />
<sup>3</sup> To enable this feature, go to &ldquo;Settings &gt; Writing &gt; Remote Publishing&rdquo; in the WP Admin</p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/06/xmlrpc-php-security/">Permalink</a> | <a href="http://digwp.com/2009/06/xmlrpc-php-security/#comments">17 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2009/06/xmlrpc-php-security/&title=The xmlrpc.php File and Site Security">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/header/" rel="tag">header</a>, <a href="http://digwp.com/tag/security/" rel="tag">Security</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/06/xmlrpc-php-security/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Create a Stunning Lightbox-Style Random-Post Header Gallery</title>
		<link>http://digwp.com/2009/06/random-lightbox-header-gallery/</link>
		<comments>http://digwp.com/2009/06/random-lightbox-header-gallery/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 14:09:43 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[custom-fields]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[lightbox]]></category>
		<category><![CDATA[loop]]></category>

		<guid isPermaLink="false">http://diggingintowordpress.com/?p=150</guid>
		<description><![CDATA[In this tutorial, we&#8217;re going to take advantage of two of WordPress&#8217; most powerful features, get_posts() and custom fields, to create a stunning random lightbox-style header gallery for your post images. Displayed before the standard post loop, this lightbox gallery will randomly display the images that are associated with your posts while also providing a [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial, we&rsquo;re going to take advantage of two of WordPress&rsquo; most powerful features, <code>get_posts()</code> and custom fields, to create a stunning random lightbox-style header gallery for your post images. Displayed <em>before</em> the standard post loop, this lightbox gallery will randomly display the images that are associated with your posts while also providing a descriptive title link to the post itself. Here is a graphical representation that will help us visualize what we are going to do:</p>
<p><img src="http://digwp.com/wp-content/blog-images/lightbox-tutorial.jpg" alt="" title="" /><br /><small>Random post-display functionality with lightbox-style popup image and title post link</small></p>
<p>The key to setting this up involves creating a set of custom fields for each post and then displaying the information randomly before the main post loop. Let&rsquo;s begin with the custom fields.</p>
<p><span id="more-150"></span></p>
<h3>Setting up the custom fields</h3>
<p>If you have already been taking advantage of <a href="http://perishablepress.com/press/2008/12/17/wordpress-custom-fields-tutorial/" title="WordPress Custom Fields, Part I: The Basics">WordPress custom fields</a>, then you already understand the basic idea here. For each post that you would like to have appear randomly in the header of your theme, create the following custom fields:</p>
<p><img src="http://digwp.com/wp-content/blog-images/custom-fields.gif" alt="" title="" /><br /><small>Custom-field data associated with each randomly displayed post</small></p>
<p>Notice that we are using <em>relative</em> file paths for the images. This trick ensures maximum flexibility and portability for our custom-field data. Also note the two different images we are using for each post: a full-size image that will be displayed in the lightbox popup, and a cropped or resized version of that same image for display in the random header.</p>
<p>Once you have associated these custom fields with a few of your posts, it is time for a little <code>get_posts()</code> action to display the random content in your active theme.</p>
<h3>Editing your WordPress theme files</h3>
<p>One of the great things about WordPress custom fields is that they enable you to display your content in just about any way imaginable. In this tutorial, we are going to display our custom-field data in the header area for every page on the site. Thus, we open our theme&rsquo;s <code>header.php</code> file and add the following code:</p>
<pre><code>&lt;?php $random = get_posts('showposts=1&amp;orderby=rand'); foreach($random as $post) : setup_postdata($post); ?&gt;

&lt;p&gt;
	&lt;a href="http://domain.tld&lt;?php echo get_post_meta($post-&gt;ID, 'randomImage', true); ?&gt;" title="&lt;?php echo get_post_meta($post-&gt;ID, 'randomCaption', true); ?&gt;" class="thickbox"&gt;
		&lt;img src="http://domain.tld&lt;?php echo get_post_meta($post-&gt;ID, 'randomBanner', true); ?&gt;" alt="" /&gt;
	&lt;/a&gt;
	&lt;small&gt;&lt;a href="http://domain.tld&lt;?php echo get_post_meta($post-&gt;ID, 'randomLink', true); ?&gt;"&gt;&lt;?php echo get_post_meta($post-&gt;ID, 'randomTitle', true); ?&gt;&lt;/a&gt;&lt;/small&gt;
&lt;/p&gt;

&lt;?php endforeach; ?&gt;</code></pre>
<p>As mentioned, this code goes before the normal WordPress loop and calls data from each of the five custom fields that have been added to your posts. Instead of using the more powerful <code>query_posts()</code> for this random post display, we use the simpler <a href="http://codex.wordpress.org/Template_Tags/get_posts" title="WordPress Codex: Template Tags/get posts">get_posts()</a> function instead. It does everything we need while eliminating unnecessary variables and potential complications.</p>
<p>A few other points of interest for this WordPress snippet; notice we are setting the randomness and limiting the post display to one (&nbsp;<code>1</code>&nbsp;) via two parameters in the <code>get_posts()</code> function. Once the query has been setup, we are using the <a href="http://codex.wordpress.org/Function_Reference/get_post_meta" title="Function Reference/get post meta">get_post_meta()</a> tag to populate the following markup with their respective custom-field values:</p>
<pre><code>&lt;p&gt;
	&lt;a href="[randomImage]" title="[randomCaption]" class="thickbox"&gt;
		&lt;img src="[randomBanner]" alt="" /&gt;
	&lt;/a&gt;
	&lt;small&gt;&lt;a href="[randomLink]"&gt;[randomTitle]&lt;/a&gt;&lt;/small&gt;
&lt;p&gt;</code></pre>
<p>This demonstrates the incredible design flexibility enabled by WordPress custom fields. Once this code is in place, it is time to wrap things up by implementing the JavaScript-powered lightbox functionality.</p>
<h3>Adding the JavaScript</h3>
<p>To finish things off, let&rsquo;s make that random-banner image really &ldquo;pop&rdquo; by implementing some JavaScript-powered lightbox functionality. As you probably know, there are <a href="http://planetozh.com/projects/lightbox-clones/" title="The Lightbox Clones Matrix">many lightbox clones</a> from which to choose, but for this tutorial we turn to Cody Lindley&rsquo;s excellent <a href="http://jquery.com/demo/thickbox/" title="ThickBox 3.1">Thickbox</a> script:</p>
<blockquote><p>ThickBox is a webpage UI dialog widget written in JavaScript on top of the jQuery library. Its function is to show a single image, multiple images, inline content, iframed content, or content served through AJAX in a hybrid modal.</p></blockquote>
<p>Using Thickbox is <em>so</em> easy, it almost feels like I&rsquo;m just being lazy for using it. In fact, we have already setup our WordPress code for use with Thickbox by simply adding the <code>class="thickbox"</code> attribute to the random-banner anchor element. The only other thing that really needs to be done is to upload the Thickbox script and accompanying <acronym title="Cascading Style Sheets">CSS</acronym> file to your server and link to them from the <code>&lt;head&gt;</code> section of your <code>header.php</code> file:</p>
<pre><code>&lt;link rel="stylesheet" href="http://domain.tld/wp-content/css/thickbox.css" type="text/css" media="screen" /&gt;
&lt;script type="text/javascript" src="http://domain.tld/wp-content/javascript/thickbox-compressed.js"&gt;&lt;/script&gt;</code></pre>
<h3>Putting it all together</h3>
<p>Once everything is in place, your random-post gallery should be working great. To see a working example of this technique, check out the header area of <a href="http://eightyeightteeth.com/" title="EightyEightTeeth.com - Graphics Portfolio of Thane Champie">Thane Champie&rsquo;s Graphics Portfolio site</a>. That particular implementation of this method features a few more bells and whistles, but the basic functionality is the same.</p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/06/random-lightbox-header-gallery/">Permalink</a> | <a href="http://digwp.com/2009/06/random-lightbox-header-gallery/#comments">15 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2009/06/random-lightbox-header-gallery/&title=Create a Stunning Lightbox-Style Random-Post Header Gallery">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/custom-fields/" rel="tag">custom-fields</a>, <a href="http://digwp.com/tag/header/" rel="tag">header</a>, <a href="http://digwp.com/tag/javascript/" rel="tag">JavaScript</a>, <a href="http://digwp.com/tag/layout/" rel="tag">layout</a>, <a href="http://digwp.com/tag/lightbox/" rel="tag">lightbox</a>, <a href="http://digwp.com/tag/loop/" rel="tag">loop</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/06/random-lightbox-header-gallery/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Including jQuery in WordPress (The Right Way)</title>
		<link>http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/</link>
		<comments>http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 01:58:16 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://modernwordpress.com/?p=36</guid>
		<description><![CDATA[If you want, you can just download jQuery, put it on your server and link to it from your header.php file in the &#60;head&#62; section. But that can cause you grief. For one thing, some plugins use the jQuery library, and they are going to load it as well. This can cause problems. How was [...]]]></description>
			<content:encoded><![CDATA[<p>If you want, you can just download <a href="http://jquery.com">jQuery</a>, put it on your server and link to it from your <tt>header.php</tt> file in the <tt>&lt;head&gt;</tt> section. But that can cause you grief. For one thing, some plugins use the jQuery library, and they are going to load it as well. This can cause problems. How was your plugin to know you already had it loaded?</p>
<p>Another thing is that WordPress already includes a copy of jQuery. Here is how you can load up jQuery in your theme the smart (and intended) way. Put the following code in your <tt>header.php</tt> file in the <tt>&lt;head&gt;</tt> section:</p>
<pre><code>&lt;?php wp_enqueue_script("jquery"); ?&gt;

&lt;?php wp_head(); ?&gt;</code></pre>
<p><span id="more-36"></span></p>
<p>Your theme probably already has the <tt>wp_head</tt> function, so just make sure you call the <tt>wp_enqueue_script</tt> function BEFORE that. Now you are all set to call your own jQuery JavaScript file, AFTER the <tt>wp_head</tt> function.</p>
<pre><code>&lt;script type="text/javascript"
   src="&lt;?php bloginfo("template_url"); ?&gt;/js/yourScript.js"&gt;&lt;/script&gt;</code></pre>
<p>You are ready to rock, but there are still some considerations. For example, safeguarding yourself from the future possibility of conflict with other libraries. You really shouldn&#8217;t be using multiple JS libraries to begin with, but&#8230; better safe than sorry.</p>
<p>To be super-safe, you can put jQuery into &#8220;no conflict&#8221; mode and use a different shortcut for jQuery. In this case &#8220;$j&#8221; instead of the default &#8220;$&#8221;. The standard &#8220;$&#8221;, for example, can conflict with Prototype. Here is an example of a safe bit of jQuery JavaScript:</p>
<pre><code>var $j = jQuery.noConflict();

$j(function(){

    $j("#sidebar li a").hover(function(){
    	$j(this).stop().animate({
    		paddingLeft: "20px&amp;"
    	}, 400);
    }, function() {
    	$j(this).stop().animate({
    		paddingLeft: 0
    	}, 400);
    });

});</code></pre>
<p>Can you recognize this bit of code? We use it right here on Modern WordPress to do the cool &#8220;link nudging&#8221; in the sidebar!</p>
<h3>Translations</h3>
<ul>
<li><a href="http://webhostingrating.com/libs/including-jquery-in-wordpress-be">Belorussian translation</a></li>
</ul>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/">Permalink</a> | <a href="http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/#comments">59 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/&title=Including jQuery in WordPress (The Right Way)">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/header/" rel="tag">header</a>, <a href="http://digwp.com/tag/jquery/" rel="tag">jquery</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/feed/</wfw:commentRss>
		<slash:comments>59</slash:comments>
		</item>
		<item>
		<title>Custom WordPress Title Tags</title>
		<link>http://digwp.com/2009/06/custom-wordpress-title-tags/</link>
		<comments>http://digwp.com/2009/06/custom-wordpress-title-tags/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 23:03:33 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[tags]]></category>
		<category><![CDATA[title]]></category>

		<guid isPermaLink="false">http://modernwordpress.com/?p=22</guid>
		<description><![CDATA[By default, WordPress provides a decent way of including &#60;title&#62; information for your posts, pages, and various archive views. Using WordPress&#8217; built-in template tag, &#8220;wp_title()&#8221;, we can specify several useful parameters, including: sep &#8211; a string value indicating the separator displayed before the title echo &#8211; a boolean value determining whether or not the title [...]]]></description>
			<content:encoded><![CDATA[<p>By default, WordPress provides a decent way of including <code>&lt;title&gt;</code> information for your posts, pages, and various archive views. Using WordPress&rsquo; built-in template tag, &ldquo;<code>wp_title()</code>&rdquo;, we can specify several useful parameters, including:</p>
<ul>
<li><code>sep</code> &ndash; a string value indicating the separator displayed before the title</li>
<li><code>echo</code> &ndash; a boolean value determining whether or not the title is displayed</li>
<li><code>seplocation</code> &ndash; specifies the position of sep string, either left or right of the title</li>
</ul>
<p>Here is the basic format for this tag:</p>
<pre><code>&lt;?php wp_title('sep', 'echo', 'seplocation'); ?&gt;</code></pre>
<p>..which is typically combined with the <code>bloginfo('name')</code> tag and used in the <code>header.php</code> file as follows:</p>
<pre><code>&lt;head&gt;
&lt;title&gt;&lt;?php wp_title(' | ', 'echo', 'right'); ?&gt;&lt;?php bloginfo('name'); ?&gt;
&lt;/head&gt;</code></pre>
<p><span id="more-22"></span></p>
<p>This would produce the following output for each of the following page types:</p>
<ul>
<li>The Home page &ndash; outputs the name of the site</li>
<li>Individual pages &ndash; page title | name of site</li>
<li>Single post views &ndash; post title | name of site</li>
<li>Archived post views &ndash; outputs the name of the site</li>
<li>Date-based archives &ndash; year and/or month | name of site</li>
<li>Category archives &ndash; category title | name of site</li>
<li>Author archives &ndash; public username | name of site</li>
<li>404 error pages &ndash; outputs the name of the site</li>
<li>Search results &ndash; outputs the name of the site</li>
<li>Tag archives &ndash; tag name | name of site</li>
</ul>
<p>For the average blog, this works fine; most pages include the title as well as the blog name, while those without specific page names simply output the name of the site instead. To go above and beyond, however, a little more preparation is needed. For example, rather than output only the blog name for search and tag pages, why not specify the exact tag or search term being displayed? And what about archive pages? We can customize those as well using the following code:</p>
<pre><code>&lt;title&gt;
&lt;?php
if (is_category()) {
	echo 'Category: '; wp_title(''); echo ' - ';

} elseif (function_exists('is_tag') &amp;&amp; is_tag()) {
	single_tag_title('Tag Archive for &amp;quot;'); echo '&amp;quot; - ';

} elseif (is_archive()) {
	wp_title(''); echo ' Archive - ';

} elseif (is_page()) {
	echo wp_title(''); echo ' - ';

} elseif (is_search()) {
	echo 'Search for &amp;quot;'.wp_specialchars($s).'&amp;quot; - ';

} elseif (!(is_404()) &amp;&amp; (is_single()) || (is_page())) {
	wp_title(''); echo ' - ';

} elseif (is_404()) {
	echo 'Not Found - ';

} bloginfo('name');
?&gt;
&lt;/title&gt;</code></pre>
<p>When used in place of the default WordPress <code>wp_title()</code> tag, this code will produce clear, informative page titles for tag, search, date, author and other archive views, as well as for the dreaded 404 page. Further, this code may be modified to elaborate the various page titles however you wish, and also may be enhanced further, as explained in our book, <a href="http://digwp.com/preorder/" title="Digging into WordPress">Digging into WordPress</a>.</p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/06/custom-wordpress-title-tags/">Permalink</a> | <a href="http://digwp.com/2009/06/custom-wordpress-title-tags/#comments">3 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2009/06/custom-wordpress-title-tags/&title=Custom WordPress Title Tags">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/header/" rel="tag">header</a>, <a href="http://digwp.com/tag/tags/" rel="tag">tags</a>, <a href="http://digwp.com/tag/title/" rel="tag">title</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/06/custom-wordpress-title-tags/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Unique Body ID&#8217;s for your Pages</title>
		<link>http://digwp.com/2009/05/unique-body-ids-for-your-pages/</link>
		<comments>http://digwp.com/2009/05/unique-body-ids-for-your-pages/#comments</comments>
		<pubDate>Sat, 30 May 2009 16:46:51 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[body]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[permalink]]></category>

		<guid isPermaLink="false">http://modernwordpress.com/?p=18</guid>
		<description><![CDATA[There are many reasons you might want to get a unique ID for your tag. Let&#8217;s say you want your header elements to be a different color on your About page, you could style: h3 { color: blue; } body#about h3 { color: red; } But how do you get that ID on the About [...]]]></description>
			<content:encoded><![CDATA[<p>There are many reasons you might want to get a unique ID for your <tt><body></tt> tag. Let&#8217;s say you want your header elements to be a different color on your About page, you could style:</p>
<pre><code>h3 { color: blue; }
body#about h3 { color: red; }</code></pre>
<p>But how do you get that ID on the About page, but not on any other page? If you have your permalinks set up to show the page name, like <code>http://yoursite.com/about/</code>, you can use PHP to extract the &#8220;about&#8221; part of that URL.</p>
<p>Here is the magic:</p>
<pre><code>&lt;?php
	$url = explode('/',$_SERVER['REQUEST_URI']);
	$dir = $url[1] ? $url[1] : 'home';
?&gt;

&lt;body id="&lt;?php echo $dir ?&gt;"&gt;</code></pre>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/05/unique-body-ids-for-your-pages/">Permalink</a> | <a href="http://digwp.com/2009/05/unique-body-ids-for-your-pages/#comments">5 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2009/05/unique-body-ids-for-your-pages/&title=Unique Body ID&#8217;s for your Pages">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/body/" rel="tag">body</a>, <a href="http://digwp.com/tag/css/" rel="tag">CSS</a>, <a href="http://digwp.com/tag/header/" rel="tag">header</a>, <a href="http://digwp.com/tag/permalink/" rel="tag">permalink</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/05/unique-body-ids-for-your-pages/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

