<?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>Web Cash &#187; wordpress</title>
	<atom:link href="http://www.earn-web-cash.com/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.earn-web-cash.com</link>
	<description>Writing, Designing, and Making Money Online</description>
	<lastBuildDate>Sun, 04 Dec 2011 22:52:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Google Analytics: Inserting Into a WordPress Template</title>
		<link>http://www.earn-web-cash.com/2008/03/29/google-analytics-wordpress/</link>
		<comments>http://www.earn-web-cash.com/2008/03/29/google-analytics-wordpress/#comments</comments>
		<pubDate>Sat, 29 Mar 2008 17:00:48 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Online Tools]]></category>
		<category><![CDATA[Redirected]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Analytics]]></category>
		<category><![CDATA[Stat Tracking]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/03/29/google-analytics-wordpress/</guid>
		<description><![CDATA[Google Analytics is a great tool for gathering data about your website. You can track and analyze all kinds of data about your visitors, their navigation paths, and the effectiveness of your content. To use Google Analytics, you need to place some javascript on your website. A commonly asked question in forums is, &#8220;How do [...]]]></description>
			<content:encoded><![CDATA[<p>Google Analytics is a great tool for gathering data about your website.  You can track and analyze all kinds of data about your visitors, their navigation paths, and the effectiveness of your content.</p>
<p>To use Google Analytics, you need to place some javascript on your website.  A commonly asked question in forums is, &#8220;How do I add Google Analytics to my WordPress template?&#8221;<br />
<span id="more-184"></span></p>
<h4>Where the Analytics Code Goes</h4>
<p>When you sign up for Google Analytics, Google provides you with a short piece of javascript to place on your site.  The code should look like this.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src='&quot; + gaJsHost + &quot;google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E&quot;));
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
var pageTracker = _gat._getTracker(&quot;UA-2894597-3&quot;);
pageTracker._initData();
pageTracker._trackPageview();
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>According to Google&#8217;s instructions, this needs to be placed at the very end of your site &#8211; just before the closing body tag.  To do this, we need to find the closing body tag on the WordPress template.</p>
<h4>Look In Footer.php</h4>
<p>As we previously discovered, a <a href="http://www.earn-web-cash.com/2008/03/10/wordpress-template-basics/">WordPress template</a> is made up of a series of files.  Three basic files &#8211; header.php, sidebar.php, and footer.php &#8211; help build the components of the page.</p>
<p>If your WordPress template follows normal conventions, the closing body tag should be in the footer.php file.</p>
<p>Go to your themes directory of the WordPress installation, navigate to your current theme, and open footer.php.  You should see something like this at the end.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;?php wp_footer<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p>Add a blank line before the closing body tag.  Simply copy and paste the javascript code that Google provides on that blank line, save the file, and you&#8217;re good to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/03/29/google-analytics-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving WordPress: Individual 301 Redirects with PHP</title>
		<link>http://www.earn-web-cash.com/2008/03/23/moving-wordpress-individual-301-redirects-with-php/</link>
		<comments>http://www.earn-web-cash.com/2008/03/23/moving-wordpress-individual-301-redirects-with-php/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 01:51:58 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Redirect]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/03/23/moving-wordpress-individual-301-redirects-with-php/</guid>
		<description><![CDATA[I recently decided to move part of an old blog to an independent site. In order to maintain the meager search engine and referral traffic that the old pages had, I planned on using 301 Redirects. I figured that I would re-create each of the old articles (~10 total articles) on the new site and [...]]]></description>
			<content:encoded><![CDATA[<p>I recently decided to move part of an <a href="http://walkere.frih.net/issues">old blog</a> to an <a href="http://rolling-horde.net">independent site</a>.</p>
<p>In order to maintain the meager search engine and referral traffic that the old pages had, I planned on using 301 Redirects.  I figured that I would re-create each of the old articles (~10 total articles) on the new site and set up an individual 301 Redirect to send users and search engine spiders to the new location.</p>
<p>The problem, however, was that the standard .htaccess rewrite that WordPress uses was conflicting with the 301 Redirects.  For some reason, they just weren&#8217;t working &#8211; so I turned to a PHP-based solution.<br />
<span id="more-180"></span></p>
<h4>301 Redirects In htaccess</h4>
<p>Normally, you can handle a 301 Redirect with a .htaccess file.  You can do this with a single line in your .htaccess file.</p>
<pre>redirect 301 /path/to/old/file.html http://newdomain.com/file.html</pre>
<p>The first part &#8220;redirect 301&#8243; indicates the <strong>type</strong> of redirect.  This tells the browser (or the search engine spider) that the page has <strong>permanently</strong> moved to the new location.  HTTP has several other options.  The 302 Redirect, for example, indicates that the move is <strong>temporary</strong>.</p>
<p>The next two parts indicate the old path to the file and the URL of the new location.</p>
<p>Normally, that&#8217;s all there is to it.  However, WordPress adds its own layer to the .htaccess file which makes your pretty URLs work.  The URL that you request is really just a bunch of variables that tell WordPress what article to pull out of the database and display in the template.</p>
<p>Although you should be able to get the two to work together, I couldn&#8217;t.  The server was ignoring my 301 Redirect and going directly to the other rewrite rules.</p>
<h4>Using PHP to 301 Redirect a WordPress Page</h4>
<p>The solution?  PHP.</p>
<p>Creating a 301 Redirect in PHP is fairly simple.  I&#8217;d read about it before, and just the other day I came across a <a href="http://www.electrictoolbox.com/php-301-redirect/">brief article about it</a> in one of my regular RSS feeds.</p>
<p>You use the header() function to send custom headers to the user&#8217;s browser.  With these, you can tell the browser that you want to initiate a 301 Redirect.  You can then tell the browser where to go to find the article.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;HTTP/1.1 301 Moved Permanently&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: http://newdomain.com/article.html&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Simply replace the URL with the URL you want to redirect to.</p>
<h4>Making It Work With WordPress</h4>
<p>If you look in your site&#8217;s directory structure, you may realize that the path to your article doesn&#8217;t really exist.</p>
<p>Let&#8217;s say we want to redirect the article located at <a href="http://www.earn-web-cash.com/2008/03/20/useful-wordpress-plugins/">http://www.earn-web-cash.com/2008/03/20/useful-wordpress-plugins/</a>.  To use PHP, we&#8217;d need to create a PHP file to replace the article that is being redirected, and include the snippet of code above.</p>
<p>The problem is that the directory /2008/03/20/useful-wordpress-plugins/ doesn&#8217;t exist.  Those are parameters sent to the WordPress script to fetch information out of the database.</p>
<p>To make this type of redirect work, we need to <strong>create</strong> this directory structure.  Start at your root, and create the directory &#8220;2008.&#8221;  Create a directory &#8220;03&#8243; inside that.  Create a directory &#8220;20&#8243; inside that.  Finally, create the directory &#8220;useful-wordpress-plugins&#8221; inside that.</p>
<p>You&#8217;ll notice that there is a trailing slash in the URL.  In a normal directory structure, &#8220;useful-wordpress-plugins&#8221; is a directory, even though it would seem to represent the file where your article resides.  To get the browser to access a PHP file at this location, we place an index.php file in that directory.  Then, accessing the URL will automatically pull up index.php.</p>
<p>In short, create /2008/03/20/useful-wordpress-plugins/index.php, add the snippet of code above, and your redirect should work flawlessly.</p>
<p>This is a good way to move a few articles on a site to a new site.  If you&#8217;re moving an entire site, you&#8217;d definitely want to look into using the .htaccess method, or creating a PHP file that dynamically chooses what page to redirect the user to.  I only had to move 10 articles, so I created ten php files to do the work for me.</p>
<p>There is one caveat to keep in mind.  If your installation of WordPress uses the URL http://www.earn-web-cash.com/2008 to access the yearly archives, you&#8217;ll run into a problem.  /2008 will now be an actual directory &#8211; so the server will try to serve up the directory.  You&#8217;ll need to change your settings so that the archives are located in something like http://www.earn-web-cash.com/archives/2008.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/03/23/moving-wordpress-individual-301-redirects-with-php/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Five Useful, Simple WordPress Plugins</title>
		<link>http://www.earn-web-cash.com/2008/03/20/useful-wordpress-plugins/</link>
		<comments>http://www.earn-web-cash.com/2008/03/20/useful-wordpress-plugins/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 00:30:13 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Sundry Musings]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/03/20/useful-wordpress-plugins/</guid>
		<description><![CDATA[I&#8217;ve been playing around with developing WordPress sites for a while now. I love how quick and easy it is to launch a site and update content. One of the greatest features is the thousands of plug-ins available for WordPress. You can find a plug-in for just about anything you want to do &#8211; or [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing around with developing WordPress sites for a while now.  I love how quick and easy it is to launch a site and update content.</p>
<p>One of the greatest features is the thousands of plug-ins available for WordPress.  You can find a plug-in for just about anything you want to do &#8211; or if you have some PHP know-how, you can develop your own.</p>
<p>Here are five basic WordPress plug-ins that I&#8217;d recommend using for <strong>any</strong> project you start.<br />
<span id="more-179"></span></p>
<h4>Akismet &#8211; Spam Protection</h4>
<p>This plug-in comes pre-installed with WordPress &#8211; and there&#8217;s absolutely no reason you shouldn&#8217;t use it.  <a href="http://akismet.com/>Akismet</a> automatically captures most spam comments and places them in a separate &#8220;spam&#8221; category.  You don&#8217;t get bombarded with &#8220;Moderate Now&#8221; e-mails, and you can trust that your comment logs will be pretty clean.</p>
<p>Since I&#8217;ve been using it on this site (about two months), Akismet has caught a little over 900 comments.  Once a week or so, I scan through the comment log and rescue any false positives.  Occasionally a legitimate comment will get swept up, but all you need to do is select it, hit &#8220;De-spam Comment,&#8221; and it will be saved.</p>
<h4>All In One SEO Plug-In</h4>
<p>The <a href="http://wp.uberdose.com/2007/03/24/all-in-one-seo-pack/">All In One SEO Plug-In</a> is just what it sounds like.  It adds some extra functionality to tweak the SEO of each of your posts and pages.</p>
<p>For example, All In One will automatically generate a description meta tag based on your excerpt and it will automatically generate keywords based on your tags.  You can also use this to modify the title element of each page.  I&#8217;d say it&#8217;s a must have for optimizing your website.</p>
<h4>Exec-PHP</h4>
<p>Early on, I was looking for a way to execute PHP code inside a post.  WordPress doesn&#8217;t have built-in support for this, so you need to find a plug in to do it.</p>
<p>There are dozens of plug-ins that attempted to implement this feature.  <a href="http://bluesome.net/post/2005/08/18/50/">Exec PHP</a> is hands down the best that I&#8217;ve found.  You simply add regular PHP tags to your post and the PHP code will be executed properly.  I&#8217;ve never run into any bugs while using the plug-in, unlike some other plug-ins I&#8217;ve tested.</p>
<h4>Per Post CSS and JS</h4>
<p><a href="http://www.flog.co.nz/">Per Post CSS and JS</a> allows you to attach individual stylesheets or javascript files to your posts or pages.  This is great for changing the look of a specific page without creating an entirely new template.  By attaching these files to individual posts, you cut down a lot on redundancy.</p>
<p>For example, let&#8217;s say you wrote a javascript file that you use in 10% of your posts.  Why should it be attached to the other 90% of your posts?</p>
<p>I&#8217;ve also found it <strong>very</strong> useful for creating HTML/CSS/JS tutorials.  I can place my sample code in external .css and .js files and have it attached properly to the page.  This way I don&#8217;t have to write in-line styles to demonstrate functionality.</p>
<h4>WP Unformatted</h4>
<p>This simple plug-in removes all of the auto-formatting that WordPress adds to your posts.  With <a href="http://alexking.org/projects/wordpress">WP Unformatted</a>, you can add a custom field to your post to tell the plug-in to strip out all of that formatting.</p>
<p>For example, WordPress likes to wrap text in <code>&lt;p&gt;</code> tags.  Sometimes &#8211; like with forms &#8211; this is entirely undesirable.  It can mess up your carefully formatted (and syntactically correct) HTML.</p>
<p>By using WP Unformatted, you can add sophisticated mark up to your post content without worrying that WordPress will screw it up with random <code>&lt;p&gt;</code> and <code>&lt;br /&gt;</code> tags.</p>
<h4>And Many More&#8230;</h4>
<p>There are, of course, dozens of other useful plug-ins.  I&#8217;ve used plenty of other plug-ins that I liked.  However, these are the ones that I feel appeal to the widest audience.</p>
<p>No matter what you&#8217;re doing, you&#8217;ll probably find a use for spam filtering, individualized stylesheets, SEO, PHP, and clean formatting.  I would never start another project without these plug-ins.</p>
<p>What else do you find useful?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/03/20/useful-wordpress-plugins/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Anatomy of a WordPress Template: The Basics</title>
		<link>http://www.earn-web-cash.com/2008/03/10/wordpress-template-basics/</link>
		<comments>http://www.earn-web-cash.com/2008/03/10/wordpress-template-basics/#comments</comments>
		<pubDate>Mon, 10 Mar 2008 23:46:12 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/03/10/wordpress-template-basics/</guid>
		<description><![CDATA[There are tons of free WordPress templates available, but at some point you&#8217;ll probably want to modify one or make your own. Even if you know HTML pretty well, this can be a daunting task at first. WordPress templates have a decent amount of simple PHP mixed in, and you need to utilize a special [...]]]></description>
			<content:encoded><![CDATA[<p>There are tons of free WordPress templates available, but at some point you&#8217;ll probably want to modify one or make your own.  Even if you know HTML pretty well, this can be a daunting task at first.</p>
<p>WordPress templates have a decent amount of simple PHP mixed in, and you need to utilize a special file structure for the template to operate correctly.  Before you dive into making a WordPress template, let&#8217;s look at the basic structure of a WordPress template compared to a normal website template.<br />
<span id="more-175"></span></p>
<h4>Example Basic Website Template</h4>
<p>A typical website consists of a few parts &#8211; the content, a header, and a footer.  You may also have a sidebar for navigation and/or a horizontal menu bar.  The typical markup for this type of template would look something like this.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;header&quot;</span>&gt;</span>
  ...  Header Stuff Here ...
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;content&quot;</span>&gt;</span>
  ...  Main Content Here ...
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sidebar&quot;</span>&gt;</span>
  ...  This floats to a side ...
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;footer&quot;</span>&gt;</span>
  ...  Footer Stuff Here ...
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p>If you&#8217;ve learned some PHP, then you can include a series of PHP files to create your webpage template.  Chances are your header, footer, and sidebar are the same for all or most of your pages &#8211; so it makes sense to create them one time each.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;?php include<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'header.php'</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;content&quot;</span>&gt;</span>
  ...  Main Content Here ...
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;?php include<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'sidebar.php'</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;?php include<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'footer.php'</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span></pre></div></div>

<p>Nothing too complicated here.  Just a simple, barebones template.</p>
<h4>What Does a WordPress Template File Look Like?</h4>
<p>Although the terminology is a bit different, a WordPress template has the same basic structure.  Let&#8217;s look at a pared down version of the default template&#8217;s index.php file.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;?php get_header<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;content&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;narrowcolumn&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;?php if <span style="color: #66cc66;">&#40;</span>have_posts<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> : ?&gt;</span>
    <span style="color: #009900;">&lt;?php while <span style="color: #66cc66;">&#40;</span>have_posts<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> : the_post<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post-&lt;?php the_ID(); ?&gt;</span></span>&quot;&gt;
      ... Post Info ...
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;?php endwhile; ?&gt;</span>
  <span style="color: #009900;">&lt;?php endif; ?&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;?php get_sidebar<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;?php get_footer<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span></pre></div></div>

<p>The bulk of the action here is in the &#8220;content&#8221; div.  With PHP, WordPress checks to see if any posts were retrieved from the database.  If they are, then it loops through the posts and outputs each one.</p>
<p>&#8220;Post Info&#8221; would be replaced by the markup you want to use for the actual post headings, information, and content.</p>
<p>The PHP function calls are similar to the include() calls in the earlier template.  get_header() fetches the standard header info, get_sidebar() fetches the sidebar, and get_footer() fetches the footer.  But where does WordPress find this information?</p>
<h4>Special WordPress Template Files</h4>
<p>WordPress uses some standard tempalte files to make these functions work.</p>
<p>For example, get_header() looks for the header.php file.  It&#8217;s more or less a proxy call for include(&#8216;header.php&#8217;).  To make WordPress work properly, therefore, you should include all of your header information in header.php.</p>
<p>The same goes for get_footer() and footer.php as well as get_sidebar() and sidebar.php.</p>
<p>So, to begin designing a WordPress template or to convert a regular website template to a WordPress template, you need to worry about four basic files:</p>
<ul>
<li>header.php &#8211; the header div and information</li>
<li>footer.php &#8211; the footer div and information</li>
<li>sidebar.php &#8211; the sidebar div and information</li>
<li>index.php &#8211; calls get_header(), get_footer(), and get_sidebar(), and contains the content div</li>
</ul>
<p>There are some other special files as well, but this is enough to get started.  Once you understand the basic structure of the template, you can look into customizing the information that is displayed for each post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/03/10/wordpress-template-basics/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to Time Delay Posts in WordPress</title>
		<link>http://www.earn-web-cash.com/2008/03/08/time-delay-posts-wordpress/</link>
		<comments>http://www.earn-web-cash.com/2008/03/08/time-delay-posts-wordpress/#comments</comments>
		<pubDate>Sat, 08 Mar 2008 17:06:28 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[mod]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/03/08/time-delay-posts-wordpress/</guid>
		<description><![CDATA[One reason I&#8217;ve heard people say that they prefer a full-blown CMS to WordPress is that WordPress doesn&#8217;t allow time delayed posting. I was about to figure out a way to mod WordPress to make this possible &#8211; until I realized that there is some decent built-in functionality for time delaying. You can easily delay [...]]]></description>
			<content:encoded><![CDATA[<p>One reason I&#8217;ve heard people say that they prefer a full-blown CMS to WordPress is that WordPress doesn&#8217;t allow time delayed posting.  I was about to figure out a way to mod WordPress to make this possible &#8211; until I realized that there is some decent built-in functionality for time delaying.</p>
<p>You can easily delay the release of your posts into the main indexes (front page, archives, &#8220;Recent Posts&#8221; list, etc).  With a little bit of code, you can also restrict people from viewing the page before its appointed &#8220;Published&#8221; date.<br />
<span id="more-173"></span></p>
<h4>Delaying Publication: Setting a Date</h4>
<p>If all you want to do is delay the date and time that an article is &#8220;released&#8221; on your page&#8217;s index, you don&#8217;t have to do a whole lot of work.</p>
<p>Every article you post is &#8220;stamped&#8221; with a time by WordPress.  When you hit the &#8220;Publish&#8221; button, it checks the current time on the server and attaches that to your post.</p>
<p>You may not have noticed, but there&#8217;s an option for you to edit this time while you are working on the article.  For example, you could set the date back a week and backdate one of your posts.  For our purposes, we&#8217;ll set the date <strong>ahead</strong> &#8211; and WordPress won&#8217;t display your post in any indexes until that date arrives.</p>
<p><a href='http://www.earn-web-cash.com/wp-content/uploads/2008/03/edit-timestamp-ss.png' title='Screenshot of the Edit Timestamp Widget'><img class='alignright' src='http://www.earn-web-cash.com/wp-content/uploads/2008/03/edit-timestamp-ss.thumbnail.png' alt='Screenshot of the Edit Timestamp Widget' /></a>In the &#8220;Write&#8221; section of your Dashboard, you should have a column of widgets on the righthand side (Categories, Discussion, Post Slug, etc).  If you scroll down a bit, there should be one titled &#8220;Post Timestamp.&#8221;  If you don&#8217;t see anything, click the &#8220;+&#8221; button in the title.</p>
<p>To set a custom release date, select &#8220;Edit Timestamp.&#8221;  Then use the inputs to enter the date and time you want the article released.  Voila &#8211; you&#8217;re done.</p>
<h4>Restricting Access to the Page</h4>
<p>For most people, this is good enough.  Your readers aren&#8217;t going to be able to find the article without a link to it appearing on your front page or in your RSS feed.</p>
<p>However, if your readers <strong>do</strong> know the link to the page, somehow, they can still access it directly.  If you want to prevent that, you&#8217;ll need to add a few lines of code to your template files.</p>
<p>We&#8217;re going to edit the &#8220;single.php&#8221; template file &#8211; the file responsible for formatting and displaying a single post.  After the page retrieves the post, we&#8217;re going to perform a check to see if the published date of the article is in the future.</p>
<p>If it is, we&#8217;ll display an alternative message to tell the user the article isn&#8217;t published yet.  Otherwise, the article will be displayed as normal.</p>
<h4>Editing Single.php</h4>
<p>Your template file probably doesn&#8217;t look exactly like mine, but there should be some very basic similarities.</p>
<p>If you open single.php, the page is displayed within &#8220;the loop.&#8221;  It&#8217;s how every WordPress template works.  The loop always begins with a line similar to this.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>This checks to see if a page was found in the database.  If it was, it loads the page into memory and prepares to output it.  The loop will eventually end with a line like this.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>We&#8217;re going to create a new if statement and place it in between these two lines.  The new template will look something like this.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pubDate</span> <span style="color: #339933;">&gt;</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
  &lt;h3&gt;Article Not Published Yet&lt;/h3&gt;
  &lt;p&gt;Sorry!  The article you request is not published 
    yet.  It should be available soon, so check back in a few days.&lt;/p&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">else</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
  ...  Regular post processing goes here ...
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h4>Creating the Conditional Statement</h4>
<p>The only thing we have to do now is create a functioning conditional statement that checks to see if the published date of the article is in the past or the future.</p>
<p>To do that, we&#8217;ll use a few functions &#8211; get_the_time (a WordPress function to get the post&#8217;s timestamp), strtotime (a PHP function to convert a date string to a timestamp), and time (a php function to get the current tie).</p>
<p>get_the_time doesn&#8217;t return the actual time stamp &#8211; it returns a formatted date string, like &#8220;March 9, 2008, 11:13:35.&#8221;  You can specify how it&#8217;s formatted, just like you would with PHP&#8217;s date function.</p>
<p>To get the timestamp, we&#8217;re going to format the time string in a special way so that strtotime() can convert it back to a full timestamp (preserving the exact time the article should be published).  Then we compare that timestamp to the system time and see if the date has passed or not.</p>
<p>Use this if statement in the code above, and you should be good to go.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span>get_the_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'F j, Y, H:i:s'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>If you time delay an article and someone tries to access the article directly, they will now see your alternate message.  You should of course personalize that to something appropriate for your site.</p>
<p>You can also apply the same concept to &#8220;Pages&#8221; in WordPress.  You&#8217;ll need to edit the page.php template file and insert the same snippet of code there.</p>
<p>What are you waiting for?  Go write some articles for the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/03/08/time-delay-posts-wordpress/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Add Custom Loops (Queries) to WordPress</title>
		<link>http://www.earn-web-cash.com/2008/03/02/wordpress-custom-loops-queries/</link>
		<comments>http://www.earn-web-cash.com/2008/03/02/wordpress-custom-loops-queries/#comments</comments>
		<pubDate>Sun, 02 Mar 2008 21:38:06 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[mod]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/03/02/wordpress-custom-loops-queries/</guid>
		<description><![CDATA[If you look at your WordPress template, the thing that drives your page is called &#8220;the loop.&#8221; That&#8217;s WordPress speak for looping through the result set (the posts) retrieved from the database. If you wanted to make custom queries, you could certainly do that by diving straight into the database. However, WordPress comes with some [...]]]></description>
			<content:encoded><![CDATA[<p>If you look at your WordPress template, the thing that drives your page is called &#8220;the loop.&#8221;  That&#8217;s WordPress speak for looping through the result set (the posts) retrieved from the database.</p>
<p>If you wanted to make custom queries, you could certainly do that by diving straight into the database.  However, WordPress comes with some built in functions for helping you query the database and display the results.  By using these template tags, you can add custom loops in your template to display other post information.<br />
<span id="more-167"></span></p>
<h4>Looking At the Main Loop</h4>
<p>If you look in any of your templates, you&#8217;ll see a loop similar to the one below.  This basic loop just loops through all the articles, outputs the title and content.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;h2&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/h2&gt;
&lt;div&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/div&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>WordPress has a nasty habit of using that weird while/if syntax, where things aren&#8217;t enclosed in brackets.  Aside from the weird sytnax, this is a very simple while loop.</p>
<p>First, if (have_posts()) checks to see if there is any data in the queue to be outputted.  If there is, it starts a while loop that uses the same check &#8211; have_posts() &#8211; to see if it should continue.</p>
<p>The thing that moves this along is the_post().  This loads the next post in the result set into memory and prepares it for outputting.</p>
<p>The next few lines do our basic output.  the_title() is the template tag for outputting the title of the current article, while the_content() outputs the text of the article.</p>
<p>Finally, we wrap up the while loop and the if statement.  If there were more articles in the queue (like on an index/archive page), it would loop through for each article.</p>
<h4>Where Do the Articles Come From?</h4>
<p>When you load a page in WordPress, you use a query string.  The most basic one would be <code>index.php?p=5</code>.  That tells WordPress to load the article where the post id is 5.</p>
<p>You may not realize it if you&#8217;re using pretty URLs, but every URL you request on your blog has one of these query strings built-in.  It tells WordPress to load a list of articles (for an archive, category, or index) or to simply load one article or page.</p>
<p>There&#8217;s nothing stopping you from utilizing this process for other purposes, though.  Rather than simply looping through the result-set created by the query string, you can use the query_posts() function to create your own custom queries &#8211; and then loop through them.</p>
<h4>Example Please&#8230;?</h4>
<p>Here&#8217;s how it works.  You call query_posts() with a query string.  That loads the database results and prepares for the loop.  Then, you loop through like we did above to output information on the articles.</p>
<p>Let&#8217;s say you want to fetch the latest article that was tagged with both &#8220;foo&#8221; and &#8220;bar.&#8221;  Here&#8217;s how you do it.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">query_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;tag=foo+bar&amp;showposts=1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//  Create the loop here</span></pre></div></div>

<p>We passed two parameters here.  &#8220;tag=foo+bar&#8221; tells WordPress to fetch articles that have both of those tags.  &#8220;showposts=1&#8243; tells WordPress to only fetch one article.  By default, they&#8217;re sorted by date and time, so we automatically fetch the latest one.</p>
<h4>You Don&#8217;t Always Need Plug-ins</h4>
<p>This is such a great tool because it lets you avoid using some basic plug-ins.  Plug-ins essentially help you perform these extra queries &#8211; like the latest posts, similar posts, etc.  But they can also be restricting if they don&#8217;t do exactly what you want.</p>
<p>By using query_posts() to fetch your own information, you can get WordPress to do exactly what you want.</p>
<p>For example, let&#8217;s say you write movie reviews and you want to display the latest ones in your sidebar.  Rather than look for a plug-in that displays exactly what you want it to, you can tag all of your movie reviews with &#8220;Movie Review&#8221; and query for those specific posts. </p>
<p>Then you can easily create the output you want, rather than the output someone else designed.</p>
<p>This is just a taste of what you can do with query_posts() and custom loops in WordPress.  You&#8217;ll need to try it out for yourself to fully understand it, and I&#8217;d suggest you take a look at the <a href="http://codex.wordpress.org/Template_Tags/query_posts">documentation on query_posts()</a> for a list of parameters and the <a href="http://codex.wordpress.org/Template_Tags/">documentation on template tags</a> for a full list of output tags.</p>
<p>Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/03/02/wordpress-custom-loops-queries/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to Only Show the Digg Badge for Popular Posts</title>
		<link>http://www.earn-web-cash.com/2008/02/18/digg-badge-popular-posts/</link>
		<comments>http://www.earn-web-cash.com/2008/02/18/digg-badge-popular-posts/#comments</comments>
		<pubDate>Mon, 18 Feb 2008 19:45:09 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Online Tools]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[digg]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/02/18/digg-badge-popular-posts/</guid>
		<description><![CDATA[Digg can be a great source of traffic and recognition for tech related blogs. Some people take it to the extreme though, and show the &#8220;Digg This&#8221; badge on every article they write. As others have pointed out, this can be counter-productive. People don&#8217;t like to read articles that have just one Digg &#8211; they [...]]]></description>
			<content:encoded><![CDATA[<p>Digg can be a great source of traffic and recognition for tech related blogs.  Some people take it to the extreme though, and show the &#8220;Digg This&#8221; badge on every article they write.</p>
<p>As <a href="http://www.pronetadvertising.com/articles/why-the-digg-button-gets-you-buried-not-dugg11995.html">others have pointed out</a>, this can be counter-productive.  People don&#8217;t like to read articles that have just one Digg &#8211; they seem unpopular.</p>
<p>So here&#8217;s a solution: use the <a href="http://www.earn-web-cash.com/scripts-plugins-and-modules/wp-plugin-digg-badge/">Conditional &#8220;Digg This&#8221; WordPress Plugin</a> to only show the Digg Badge for articles that have a certain number of Diggs.<br />
<span id="more-129"></span></p>
<h5>Why Shouldn&#8217;t You Show the Digg Badge on Every Article?</h5>
<p>It&#8217;s easy enough to plaster the Digg Badge in your template or use a plug-in to add it to every post.  Most of your posts aren&#8217;t going to be popular though.  You&#8217;ll get at most one or two Diggs&#8230; nothing to write home about.</p>
<p>When a user opens your article, he or she might be impressed by &#8220;100 Diggs.&#8221;  He or she definitely won&#8217;t be impressed by &#8220;1 Digg.&#8221;  That&#8217;s a hint that your article wasn&#8217;t anything special &#8211; so why should the reader keep going?</p>
<h5>Using the Plugin to Only Show the Badge on Popular Articles</h5>
<p>The <a href="http://www.earn-web-cash.com/scripts-plugins-and-modules/wp-plugin-digg-badge/">Conditional Digg This</a> plug-in was designed to address this issue.</p>
<p>All you need to do is download the source code, upload it to your plugins directory, unpack the tar.gz, and click &#8220;Activate.&#8221;  You don&#8217;t need to modify any settings or insert anything into your template.  It&#8217;s all automated.</p>
<h5>How Does It Work?</h5>
<p>The basic concept behind the plugin is this:</p>
<ul>
<li>Load a story in your WordPress Blog</li>
<li>Check the Digg API to see how many diggs the article has</li>
<li>If the article has 10 or more diggs, show the badge&#8230;</li>
<li>Otherwise, leave it alone.</li>
</ul>
<p>Originally, I coded the plug-in to use a php function to access the API and check the number of Diggs each article had as it loaded.  This worked perfectly &#8211; but it took a while.  Sometimes, the API is slow to respond.  If the API took 8 seconds to spit back a response, that meant your page would take 8 extra seconds to load up.</p>
<p>Even if the API was responding quickly, this was a problem for the front page and category pages.  At best, the API takes about .25 to .5 seconds to respond &#8211; and with 10-15 checks on a page&#8230; you&#8217;re still waiting a good long time for the page to load.</p>
<h5>Load First, Check the API Later</h5>
<p>The solution I came up with was to use some nifty AJAX to perform the API checking behind the scenes.</p>
<p>The plug-in creates an AJAX request for each article.  It sends information to a php script which accesses the Digg API behind the scenes.  The page loads up instantly and AJAX will quietly do its thing.  When the response is ready, it&#8217;ll change the page to include the Digg This badge if necessary.</p>
<p>So, the next time you want to display a &#8220;Digg This&#8221; badge on your article, think about how many diggs your article has already.  Or, use the <a href="http://www.earn-web-cash.com/scripts-plugins-and-modules/wp-plugin-digg-badge/">Conditional &#8220;Digg This&#8221; WordPress Plugin</a> to automatically add a badge to your popular articles.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/02/18/digg-badge-popular-posts/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Fixing a WP Plugin: Per-Post CSS and JS</title>
		<link>http://www.earn-web-cash.com/2008/02/17/per-post-css-js/</link>
		<comments>http://www.earn-web-cash.com/2008/02/17/per-post-css-js/#comments</comments>
		<pubDate>Sun, 17 Feb 2008 22:18:52 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/02/17/per-post-css-js/</guid>
		<description><![CDATA[A few weeks ago, I installed the &#8220;Per Post CSS and JS&#8221; plugin for WordPress. This allows you to add a custom field to your post and include extra .css or .js files to link to that individual page. I only realized today &#8211; while testing something else &#8211; that the plugin had been firing [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago, I installed the &#8220;Per Post CSS and JS&#8221; plugin for WordPress.  This allows you to add a custom field to your post and include extra .css or .js files to link to that individual page.</p>
<p>I only realized today &#8211; while testing something else &#8211; that the plugin had been firing off warning messages because of an oversight in the code.  Warning messages annoy me, so I decided to fix it up.<br />
<span id="more-124"></span></p>
<h5>Where&#8217;s the Error?</h5>
<p>The plug-in consists of one file &#8211; <a href='http://www.earn-web-cash.com/wp-content/uploads/2008/02/per-post-css.txt' title='Per Post CSS and JS WP Plugin'>per-post-css.php</a>.</p>
<p>Towards the end of the function per_post_css_js, the script loops through any retrieved CSS and JS files.  During these loops, the link tags are added to the head element of the page.</p>
<p>Here&#8217;s the line that deals with CSS stylesheets.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$array_css</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$css</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
  <span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&lt;style type=<span style="color: #000099; font-weight: bold;">\&quot;</span>text/css<span style="color: #000099; font-weight: bold;">\&quot;</span> media=<span style="color: #000099; font-weight: bold;">\&quot;</span>screen<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt; @import url(&quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$css</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;); &lt;/style&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Notice anything potentially wrong here?  What happens if there are <strong>no</strong> custom CSS files attached to your page?</p>
<p>Foreach looks for an array ($array_css).  If a value is passed to foreach that is not an array, it&#8217;ll fire off a warning &#8211; and that&#8217;s just what it did.</p>
<p>The fix is simple enough.  Before attempting to iterate the loop, first check to see that $array_css (and later $array_js) is in fact an array.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array_css</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$array_css</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$css</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
		<span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&lt;style type=<span style="color: #000099; font-weight: bold;">\&quot;</span>text/css<span style="color: #000099; font-weight: bold;">\&quot;</span> media=<span style="color: #000099; font-weight: bold;">\&quot;</span>screen<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt; @import url(&quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$css</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;); &lt;/style&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>It&#8217;s a minor problem that creates some inconsequential warnings&#8230; but it annoyed me so I fixed it.  If you have display_errors turned off in PHP (which I usually do) you won&#8217;t notice the problem either.</p>
<h5>Per Post CSS and JS Updated Source Code</h5>
<p>In the plug-in file, the homepage is listed as <a href="http://www.flog.co.nz">http://www.flog.co.nz</a>.  Oddly enough, I didn&#8217;t see a reference to the script on the page anymore, although the author still updates the page.</p>
<p>When I searched for a new copy of Per Post CSS and JS, I found a listing in a WP Plugin Directory &#8211; which pointed to an old post on flog.co.nz.  That post and the link to the source code are both dead now.  Perhaps they were cleaned up to make room for new content.</p>
<p>Regardless, I&#8217;m going to re-post the <a href='http://www.earn-web-cash.com/wp-content/uploads/2008/02/per-post-css.txt' title='Per Post CSS and JS WP Plugin'>source code for the Per Post CSS and JS WP Plugin</a> here to keep it available.</p>
<p>Kudos and thanks to the original author, Adam Burmister.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/02/17/per-post-css-js/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Modify a WordPress RSS Feed Widget with Rel=Nofollow</title>
		<link>http://www.earn-web-cash.com/2008/02/09/modify-widget-nofollow/</link>
		<comments>http://www.earn-web-cash.com/2008/02/09/modify-widget-nofollow/#comments</comments>
		<pubDate>Sun, 10 Feb 2008 00:34:11 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/02/09/modify-widget-nofollow/</guid>
		<description><![CDATA[I just added an RSS feed widget to my site (see the lower right corner &#8211; the DZone links). I frequent dZone a decent amount, and I find a lot of the articles interesting. However, after some thought I became concerned that ten sitewide external links might be a bit of a drain on my [...]]]></description>
			<content:encoded><![CDATA[<p>I just added an RSS feed widget to my site (see the lower right corner &#8211; the DZone links).  I frequent dZone a decent amount, and I find a lot of the articles interesting.</p>
<p>However, after some thought I became concerned that ten sitewide external links might be a bit of a drain on my pagerank.  If only I could add &#8220;rel=nofollow&#8221; to all those links.  But there&#8217;s no option in the RSS Widget to do that.<br />
<span id="more-106"></span><br />
Well, I decided to dive in and fix it myself.</p>
<h5>Where the RSS Feed Widget is Located</h5>
<p>This is actually a very simple hack to the WordPress source files.  You&#8217;ll need to edit two lines of the file, upload it, and you should be good to go.</p>
<p>The file we&#8217;re looking for is &#8220;widgets.php&#8221; &#8211; it should be located in the wp-includes folder.  This holds all the functions related to creating widgets and it also holds the standard widgets available in the Dashboard.</p>
<p>We need to scroll down, find the &#8220;RSS Feed Widget,&#8221; find where the links are created, and add &#8220;rel=&#8217;nofollow&#8217;&#8221; to those anchor tags.</p>
<h5>Hack It Up &#8211; Add Some Code</h5>
<p>The function we&#8217;re looking for should be around line 935 &#8211; titled &#8220;wp_widget_rss.&#8221;  Once you&#8217;ve found the function, look for this line &#8211; it should be around 965.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;a class='rsswidget' href='<span style="color: #006699; font-weight: bold;">$url</span>' title='&quot;</span> <span style="color: #339933;">.</span> 
  attribute_escape<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Syndicate this content'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;'&gt;&lt;img 
  style='background:orange;color:white;border:none;' 
  width='14' height='14' src='<span style="color: #006699; font-weight: bold;">$icon</span>' alt='RSS' /&gt;&lt;/a&gt; 
  &lt;a class='rsswidget' href='<span style="color: #006699; font-weight: bold;">$link</span>' title='<span style="color: #006699; font-weight: bold;">$desc</span>'&gt;<span style="color: #006699; font-weight: bold;">$title</span>&lt;/a&gt;&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This creates the &#8220;RSS Icon&#8221; link to the original feed.  There&#8217;s a second link in there that makes the link for the title of the RSS feed.  To make these nofollow, simply add the phrase <code>rel='nofollow'</code> right after the <code>&lt;a</code>.  Be sure to use single quotes around the nofollow &#8211; or else you&#8217;ll break the PHP statement and cause an error.</p>
<p>When complete, it should look like this.  Notice that we&#8217;re adding rel=&#8217;nofollow&#8217; in two places.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;a rel='nofollow' class='rsswidget' href='<span style="color: #006699; font-weight: bold;">$url</span>' title='&quot;</span> <span style="color: #339933;">.</span> 
  attribute_escape<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Syndicate this content'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;'&gt;&lt;img 
  style='background:orange;color:white;border:none;' 
  width='14' height='14' src='<span style="color: #006699; font-weight: bold;">$icon</span>' alt='RSS' /&gt;&lt;/a&gt; 
  &lt;a rel='nofollow' class='rsswidget' href='<span style="color: #006699; font-weight: bold;">$link</span>' title='<span style="color: #006699; font-weight: bold;">$desc</span>'&gt;<span style="color: #006699; font-weight: bold;">$title</span>&lt;/a&gt;&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now scroll down a bit more to roughly line 990.  The line we&#8217;re looking for creates the individual links to the articles.  You should see this bit of code.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;li&gt;&lt;a class='rsswidget' href='<span style="color: #006699; font-weight: bold;">$link</span>'
  title='<span style="color: #006699; font-weight: bold;">$desc</span>'&gt;<span style="color: #006699; font-weight: bold;">$title</span>&lt;/a&gt;<span style="color: #006699; font-weight: bold;">$summary</span>&lt;/li&gt;&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Again, add <code>rel='nofollow'</code> right after the <code>&lt;a</code>.  The result should look like this.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;li&gt;&lt;a rel='nofollow' class='rsswidget' href='<span style="color: #006699; font-weight: bold;">$link</span>'
  title='<span style="color: #006699; font-weight: bold;">$desc</span>'&gt;<span style="color: #006699; font-weight: bold;">$title</span>&lt;/a&gt;<span style="color: #006699; font-weight: bold;">$summary</span>&lt;/li&gt;&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<h5>Upload the File</h5>
<p>That&#8217;s it.  Those two small changes should make your RSS Widgets nofollow from now on &#8211; preserving your pagerank.</p>
<p>Simply upload the file to the server (be sure to replace the old wp-includes/widgets.php) and reload your site.</p>
<p>If you run into an error, double check that you used single quotes around the &#8216;nofollow.&#8217;  The PHP string is started with a double quote (&#8220;), so if you place a double-quote there you&#8217;ll prematurely end the string &#8211; and cause a parse error.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/02/09/modify-widget-nofollow/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>How to Use Custom Stylesheets on a Per Post Basis in WordPress</title>
		<link>http://www.earn-web-cash.com/2008/02/05/per-post-css-wordpress/</link>
		<comments>http://www.earn-web-cash.com/2008/02/05/per-post-css-wordpress/#comments</comments>
		<pubDate>Wed, 06 Feb 2008 01:31:55 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[stylesheet]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/02/05/how-to-use-custom-stylesheets-on-a-per-post-basis-in-wordpress/</guid>
		<description><![CDATA[Something I struggled with recently was assigning individual style sheets to posts on this WordPress blog. For example, if I was writing a CSS tutorial I didn&#8217;t want to muck up my general stylesheet with a bunch of styles &#8211; it&#8217;d be nice to write a small stylesheet and attach it only to the specific [...]]]></description>
			<content:encoded><![CDATA[<p>Something I struggled with recently was assigning individual style sheets to posts on this WordPress blog.  For example, if I was writing a CSS tutorial I didn&#8217;t want to muck up my general stylesheet with a bunch of styles &#8211; it&#8217;d be nice to write a small stylesheet and attach it only to the specific post that needs it.</p>
<p>Unfortunately, this isn&#8217;t a built in function of WordPress.  Fortunately, you can add this functionality with a plugin.<br />
<span id="more-100"></span></p>
<h5>Headspace</h5>
<p>I originally accomplished this with the <a href="http://urbangiraffe.com/plugins/headspace/">Headspace plugin</a>.</p>
<p>Headspace is an all in one SEO plugin for WordPress.  It&#8217;s major function is to allow you to add custom titles, tags, and meta descriptions to your WordPress posts.  This should help with your SEO and SERP.</p>
<p>An added bonus is that you can add individual CSS stylesheets and JS scripts to each page.  There&#8217;s an extra field in the writing page where you can add either of these two options.</p>
<p>This part of Headspace worked great.  However, I was having trouble getting the other SEO functions to work.  I was assigning descriptions and titles, but no meta tags were being generated.</p>
<h5>Replacing Headspace</h5>
<p>To fix that problem, I de-activated Headspace and got the <a href="http://wp.uberdose.com/2007/03/24/all-in-one-seo-pack/">All In One SEO Pack</a> WordPress Plugin.  It worked great, but that&#8217;s another post altogether.</p>
<p>I didn&#8217;t realize until <strong>after</strong> I had deactivated Headspace that I had also deactivated the custom CSS on a few posts/pages.  I checked the pages and low-and-behold the custom CSS didn&#8217;t exist anymore.</p>
<p>I didn&#8217;t want to re-active Headspace just for this function, so I went off in search of a better solution.</p>
<h5>Per Post CSS and Javascript</h5>
<p>I eventually stumbled on this very simple plugin &#8211; <a href="http://www.flog.co.nz/index.php/journal/per-post-css-js/">Per Post CSS and JS</a>.</p>
<p>It&#8217;s only a few short lines.  It uses the custom fields function of WordPress to add the custom link tags.  You define a CSS or JS field for a post, enter the URL, and the plug-in adds a link tag to the head section of your page.</p>
<p>It&#8217;s quite simple, and if I didn&#8217;t find a suitable script I was going to make one myself.  However, this works perfectly well and I don&#8217;t think I could really expand on it (except maybe creating the CSS and JS fields on the writing screen, instead of using the custom fields) &#8211; so I doubt I&#8217;ll be writing my own plug-in anytime soon.</p>
<p>When it&#8217;s possible, re-use.  Then focus your energy on things you <strong>need</strong> to do yourself.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/02/05/per-post-css-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

