<?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; mod</title>
	<atom:link href="http://www.earn-web-cash.com/tag/mod/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>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>
	</channel>
</rss>

