<?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>Themocracy WordPress Themes &#187; Tips</title>
	<atom:link href="http://themocracy.com/category/wordpress-tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://themocracy.com</link>
	<description>WordPress Theme Design</description>
	<lastBuildDate>Thu, 18 Aug 2011 07:34:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>A Flickr Badge using WordPress Shortcodes</title>
		<link>http://themocracy.com/2010/03/a-flickr-badge-using-wordpress-shortcodes/</link>
		<comments>http://themocracy.com/2010/03/a-flickr-badge-using-wordpress-shortcodes/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 11:22:30 +0000</pubDate>
		<dc:creator>Barrie</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=271</guid>
		<description><![CDATA[Flickr provides a neat little snippet of javaScript to supply various image galleries direct to your site - a so-named Flickr badge. Here's a good way using WordPress shortcodes to grab a gallery...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fthemocracy.com%2F2010%2F03%2Fa-flickr-badge-using-wordpress-shortcodes%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fthemocracy.com%2F2010%2F03%2Fa-flickr-badge-using-wordpress-shortcodes%2F" height="61" width="51" /></a></div><p><img src="http://themocracy.com/wp-content/uploads/2010/03/flickr-wordpress.jpg" alt="Flickr" title="flickr-wordpress" width="160" height="148" class="alignright size-full wp-image-272" /><strong>Flickr provides a neat little snippet of javaScript to supply various image galleries direct to your site &#8211; a so-named Flickr badge.</strong></p>
<p>So if your gallery is on Flickr &#8211; rather in your WordPress, which has its own gallery shortcode &#8211; a shortcode in the blog post content can be used to embed a gallery of thumbnail images, which is also a good way to demonstrate the various usages of WordPress shortcodes.</p>
<p>The HTML for a flickr badge looks something like this:-</p>
<pre class="brush: html">

&lt;div class=&quot;flickr_badge&quot;&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.flickr.com/badge_code_v2.gne?count=5&amp;display=latest&amp;size=m&amp;layout=h&amp;source=all_tag&amp;tag=fish&quot;&gt;&lt;/script&gt;&lt;/div&gt;
</pre>
<p>And the parameters work like this:-</p>
<p><strong>count</strong> <em> integer</em> 1-10. Default is 10.</p>
<p><strong>display</strong> <em>string</em> &#8216;latest&#8217; or &#8216;random&#8217;  Default is latest. </p>
<p><strong>layout</strong> <em>string</em> h, v, x - Photos are listed horizontally, vertically, or no style. Default is horizontal.  </p>
<p><strong>source</strong> <em>string</em> user, user_tag, user_set, group, group_tag, all, all_tag </p>
<p>Source implies which &#8216;account&#8217; the photos come from:- a specified user, a user set, a group, or all users, then filtered by tag if required.  Further parameters may then be required, user(ID string)  tag (string), group (integer), and set (integer,  the url …/sets/1234567/).  </p>
<p><strong>size</strong> <em>string</em> s, t, m   s stands for square (cropped, not small&#8230;), t for thumbnail, and m for medium.  t = thumbnail is the default.</p>
<p>(<a href="http://idgettr.com/">idgettr</a> is very useful for figuring out user IDs and the IDs for photosets, groups etc.)</p>
<p><strong>WordPress Shortcodes</strong></p>
<p>A shortcode has a &#8220;handler function&#8221; &#8211; which is integrated into the code by calling the function <strong>add_shortcode()</strong>. The purpose here is to supply the various parameters for our Flickr badge as parameters of the function &#8211; the query string for the Flickr call is then constructed and the javascript code output to the page.</p>
<p>In <strong>functions.php</strong></p>
<pre class="brush: php">

function flickr_badge_shortcode($atts){

//Here&#039;s our defaults
$query_atts = shortcode_atts(array(&#039;count&#039; =&gt; &#039;6&#039;, &#039;display&#039; =&gt; &#039;latest&#039;, &#039;source&#039; =&gt; &#039;user&#039;, &#039;size&#039; =&gt; &#039;t&#039;, &#039;user&#039; =&gt; &#039;&#039;, &#039;layout&#039; =&gt; &#039;x&#039;, &#039;tag&#039; =&gt; &#039;&#039;, &#039;group&#039; =&gt; &#039;&#039;, &#039;set&#039; =&gt; &#039;&#039;), $atts); 

 	return sprintf(&#039;&lt;div class=&quot;flickr_badge&quot;&gt;&lt;script src=&quot;http://www.flickr.com/badge_code_v2.gne?%s&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;/div&gt;
&#039;, http_build_query($query_atts));
}

add_shortcode(&#039;flickrbadge&#039;, &#039;flickr_badge_shortcode&#039;);
</pre>
<p>Provided you have PHP5 on the server, <strong>http_build_query()</strong> is the quick and easy way of building a query string from an array &#8211; and it&#8217;s urlencoded&#8230;.</p>
<p>Note that the empty parameters group, set etc. are required in the defaults &#8211; otherwise nothing gets passed to the constructed url via shortcode_atts().</p>
<p>So now, in a post content you can apply the shortcode tag:</p>
<p><strong>[flickrbadge count="4" layout="h" display="latest" size="t" source="all_tag" tag="fish"]</strong></p>
<p>And you should get a nice gallery of Flickr images for users to check out &#8211; once you&#8217;ve added some CSS to style the images (note the possible uses of the layout parameter here).</p>
<p>This example was of the selfclosing shortcode tag &#8211; but you can elaborate a bit, to inject more content into the shortcode function. The simplest example would be to give the gallery a custom title.</p>
<p>Again in functions.php</p>
<pre class="brush: php">

function flickr_badge_shortcode($atts, $content=NULL){

//Here&#039;s our defaults
$query_atts = shortcode_atts(array(&#039;count&#039; =&gt; &#039;6&#039;, &#039;display&#039; =&gt; &#039;latest&#039;, &#039;source&#039; =&gt; &#039;user&#039;, &#039;size&#039; =&gt; &#039;t&#039;, &#039;user&#039; =&gt; &#039;&#039;, &#039;layout&#039; =&gt; &#039;x&#039;, &#039;tag&#039; =&gt; &#039;&#039;, &#039;group&#039; =&gt; &#039;&#039;, &#039;set&#039; =&gt; &#039;&#039;), $atts);

return sprintf(&#039;&lt;div class=&quot;flickr_badge&quot;&gt;&lt;h3&gt;%s&lt;/h3&gt;&lt;script src=&quot;http://www.flickr.com/badge_code_v2.gne?%s&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;/div&gt;&#039;, $content, http_build_query($query_atts));
}

add_shortcode(&#039;flickrbadge&#039;, &#039;flickr_badge_shortcode&#039;);
</pre>
<p>And would be called from the post content with opening and closing shortcode tags:</p>
<p><strong>[flickrbadge count="4" layout="h" display="latest" size="t" source="all_tag" tag="fish"]Here&#8217;s the latest fish[/flickrbadge]</strong></p>
<p><strong>Caution!</strong><br />
Best to avoid camelCase notation in the attributes &#8211; the regex that the content is passed through to locate shortcodes  is case-insensitive.<br />
Always remember to use <strong>return</strong> in the handler function and not <strong>echo</strong>  (in this example sprintf, not printf). It&#8217;ll appear on the page &#8211; but not in the right place&#8230;</p>
<p>WordPress shortcodes are relatively simple in concept, but can be a bit fiddly in practice, keeping track of the default parameters and the use of  shortcode_atts() just needs a bit of thinking about sometimes&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2010/03/a-flickr-badge-using-wordpress-shortcodes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Calendar Functions</title>
		<link>http://themocracy.com/2010/02/php-calendar-functions/</link>
		<comments>http://themocracy.com/2010/02/php-calendar-functions/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 14:24:22 +0000</pubDate>
		<dc:creator>Barrie</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=264</guid>
		<description><![CDATA[It's really easy to get really mixed up when trying to program with date functions - lots to keep track of, calendars, timezones, daylight saving, weird months that have different numbers of days in them...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fthemocracy.com%2F2010%2F02%2Fphp-calendar-functions%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fthemocracy.com%2F2010%2F02%2Fphp-calendar-functions%2F" height="61" width="51" /></a></div><p><img src="http://themocracy.com/wp-content/uploads/2010/02/wordpress-calendar.gif" alt="" title="wordpress-calendar" width="128" height="128" class="alignright size-full wp-image-265" />It&#8217;s really easy to get really mixed up when trying to program with date functions &#8211; lots to keep track of, calendars, timezones, daylight saving, weird months that have different numbers of days in them&#8230;</p>
<p><strong>Here&#8217;s a quick rundown on the main PHP functions involved.</strong> </p>
<h3>1. checkdate()</h3>
<blockquote><p>
bool <strong>checkdate </strong> ( int $month  , int $day  , int $year  )
</p></blockquote>
<p>Does just what it says, for the Gregorian calendar, and it&#8217;s been around since PHP4 &#8211; a very quick way to ensure that the programming isn&#8217;t coming up with any silly results. Always useful!</p>
<h3>2.. date() and gmdate()</h3>
<p>From a given UNIX timestamp, <strong>date()</strong> tells you what time would be in your server timezone and <strong>gmdate()</strong> tells you what GMT it would be (or UTC, the same thing&#8230;). It is important to get the hang of the consequences of this and one way of figuring it out is to bear in mind the date() format character &#8220;Z&#8221; &#8211; the timezone offset in seconds, positive or negative. </p>
<p>No matter what the timezone is set to, these 2 expressions will produce the same result&#8230;</p>
<pre class="brush: php">
&lt;?php
	date_default_timezone_set(&#039;America/Montreal&#039;);

	echo date(&quot;Y/m/d H:i:s&quot;,(time()));
	echo gmdate(&quot;Y/m/d H:i:s&quot;,(time()+ date(&quot;Z&quot;)));

?&gt;
</pre>
<h3>3. strtotime()</h3>
<p>Takes a string and should return a Unix timestamp.</p>
<p>It does say string in &#8220;US English date format&#8221; &#8211; which means that for strtotime (&#8220;04/06/2010&#8243;) is April 6th, and not the 4th of June. (Probably no need to get into a discussion about the relative logic of the two systems here).</p>
<p><strong>strtotime</strong> has a pretty decent understanding of language &#8211; so you can do relative times:</p>
<pre class="brush: php">
strtotime(&#039;next Monday&#039;);
strtotime(&#039;+1 years&#039;);
strtotime(&#039;first day next month&#039;);
strtotime(&#039;2010-02 last day&#039;);
</pre>
<p>All return what you&#8217;d expect, based on the datetime the function&#8217;s run&#8230;</p>
<h3>4. mktime()</h3>
<p>Good for catching &#8220;overflows&#8221;. </p>
<pre class="brush: php">
echo date(&quot;M-d-Y&quot;, mktime(0, 0, 0, 12, 32, 2009)) // =&gt; Jan-01-2010
echo date(&quot;M-d-Y&quot;, mktime(0, 0, 0, 15, 31, 2009)) // =&gt; Mar-31-2010
</pre>
<p>Like strtotime, mktime doesn&#8217;t go in unit magnitude order &#8211; it&#8217;s hours, minutes, seconds, months, days, years&#8230;. why? because that&#8217;s the decision that was made&#8230;</p>
<p><strong>Find a birth day with mktime:-</strong></p>
<pre class="brush: php">
	$my_birthdate = mktime(0,0,0,5,12,72);
	print date(&quot;l&quot;, $my_birthdate);
	//gives:   Friday
</pre>
<h3>A Few  More Calendar Tricks</h3>
<p><strong>Current age</strong></p>
<pre class="brush: php">
&lt;?php  echo floor(abs(strtotime(&#039;Y&#039;) - strtotime(&#039;02/22/1968&#039;))/31536000);  ?&gt;
</pre>
<p><strong>Easter date</strong></p>
<pre class="brush: php">
&lt;?php echo date(&quot;M-d-Y&quot;, easter_date(2010));   ?&gt;     // Apr-04-2010
</pre>
<p><strong>Datetime constants</strong><br />
PHP 5.1 and later, via the DateTime class, offers a few shorthand formatting strings.</p>
<pre class="brush: php">
&lt;?php echo date(DATE_RSS); ?&gt;
//gives something like: Thu, 21 Feb 2010 09:35:44 -0800
</pre>
<p>The defined strings are <a href="http://us.php.net/manual/en/class.datetime.php#datetime.constants.types">here</a> &#8211; also good for cookies.</p>
<p><strong>Daylight Saving Problems</strong><br />
One way of cutting out possible problems with daylight saving time differences across timezones is to work in UTC, using expressions like these (and then revert back to a local timezone at the end if necessary).</p>
<pre class="brush: php">
date_default_timezone_set(&#039;UTC&#039;);

$date_utc = strtotime($date. &quot; UTC&quot;);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2010/02/php-calendar-functions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WP-Cron &#8211; automating and scheduling</title>
		<link>http://themocracy.com/2010/02/wp-cron-automating-scheduling/</link>
		<comments>http://themocracy.com/2010/02/wp-cron-automating-scheduling/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 06:51:03 +0000</pubDate>
		<dc:creator>Barrie</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=260</guid>
		<description><![CDATA[You need a cron job in your WordPress blog - something run to a schedule, hourly, daily...  Instead of fixing up a crontab and using wget or lynx, you can use WordPress's internal version of the cron job.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fthemocracy.com%2F2010%2F02%2Fwp-cron-automating-scheduling%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fthemocracy.com%2F2010%2F02%2Fwp-cron-automating-scheduling%2F" height="61" width="51" /></a></div><p><strong>You need a cron job in your WordPress blog</strong> &#8211; something run to a schedule, hourly, daily&#8230;  Instead of fixing up a crontab and using wget or lynx, you can use WordPress&#8217;s internal version of the cron job.</p>
<p>This isn&#8217;t a true cron job, with a crontab text file sitting on the server &#8211; it&#8217;s known as a pseudo-cron. Since a script can&#8217;t launch itself, it makes use of a visitor, human or maybe robot, launching it by requesting a page. So the job actually runs at the first launch <em>after</em> the scheduled time, not necessarily at the scheduled time to the exact second.</p>
<h3>wp_schedule_event()</h3>
<p>The most convenient way of using WP-Cron is to wrap it all up in a plugin &#8211; so that the scheduling can be done just the once by including it in the plugin activation function.</p>
<pre class="brush: php">
register_activation_hook(__FILE__, &#039;my_activation&#039;);
add_action(&#039;my_hourly_event&#039;, &#039;do_this_hourly&#039;);
register_deactivation_hook(__FILE__, &#039;my_deactivation&#039;); 

function my_activation() {
wp_schedule_event(time(), &#039;hourly&#039;, &#039;my_hourly_event&#039;);
}

function my_deactivation() {
	wp_clear_scheduled_hook(&#039;my_hourly_event&#039;);
}

function do_this_hourly() {
	// do something here every hour
}
</pre>
<p>The PHP time() used as an argument indicates &#8220;as of now&#8221; &#8211; so if the plugin is activated at 11:23, an hourly event is going to run at xx:23 from now onwards.</p>
<p>If your code is in for example <strong>functions.php</strong> and is executed every time the script is executed, you don&#8217;t want to keep scheduling the same event. Something like this prevents the problem:-</p>
<pre class="brush: php">
if (empty(wp_next_scheduled(&#039;my_event&#039;)))
		wp_schedule_event(time(), &#039;daily&#039;, &#039;my_event&#039;);
</pre>
<h3> WP-Cron Hourly, Recurrence Intervals</h3>
<p>Only <strong>hourly</strong>, <strong>daily</strong> and <strong>twicedaily</strong> are available immediately &#8211;  but there&#8217;s a trick to getting more and that&#8217;s to tap into the cron_schedules filter and add a key to the schedules array.</p>
<pre class="brush: php">
add_filter(&#039;cron_schedules&#039;, &#039;my_add_weekly&#039;);

function my_add_weekly( $schedules ) {
	$schedules[&#039;weekly&#039;] = array(
		&#039;interval&#039; =&gt; 604800, //that&#039;s how many seconds in a week, for the unix timestamp
		&#039;display&#039; =&gt; __(&#039;Once Weekly&#039;)
	);
	return $schedules;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2010/02/wp-cron-automating-scheduling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using JSON with WordPress</title>
		<link>http://themocracy.com/2010/02/json-wordpress/</link>
		<comments>http://themocracy.com/2010/02/json-wordpress/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 13:16:33 +0000</pubDate>
		<dc:creator>Lisa</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=258</guid>
		<description><![CDATA[With the popularity of jQuery, AJAX, and client-side programming operations in general, there's more use made of JSON as a format for getting data backwards and forwards. 

For example, the Twitter API offers data as JSON  - and more manageably than accessing their RSS XML feeds for user timelines.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fthemocracy.com%2F2010%2F02%2Fjson-wordpress%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fthemocracy.com%2F2010%2F02%2Fjson-wordpress%2F" height="61" width="51" /></a></div><p><img src="http://themocracy.com/wp-content/uploads/2010/02/json.gif" alt="json with wordpress" title="json-wordpress" width="128" height="128" class="alignright size-full wp-image-259" />With the popularity of jQuery, AJAX, and client-side programming operations in general, there&#8217;s more use made of JSON as a format for getting data backwards and forwards. </p>
<p>For example, the Twitter API offers data as JSON  &#8211; and more manageably than accessing their RSS XML feeds for user timelines etc.</p>
<pre>http://twitter.com/status/user_timeline/USERNAME.json?count=10 </pre>
<p>The issue is how to make use of JSON-encoded information in the WordPress environment &#8211; much of what is available is only recently available, so some care has to be taken about how it&#8217;s used.</p>
<h3>1. Native PHP functions</h3>
<p><strong>json_encode()</strong> and <strong>json_decode()</strong> make life very simple &#8211; but these functions are only available in PHP >= 5.2.0 and WordPress is still designed to run on significantly older versions of PHP than this. Alternatives would have to be supplied if you were thinking about releasing a plugin. There are custom-written functions to reproduce these in PHP4, see for example user contributions to <a href="http://php.net/manual/en/function.json-encode.php">json_encode</a>. These are often not 100% perfect, but one may well do all that you require&#8230;</p>
<h3>2. JSON2</h3>
<p>If you&#8217;re happy to do the work in jQuery/javaScript, WordPress 2.9 comes with JSON2 bundled, registered and ready to go&#8230;</p>
<pre class="brush: php">
add_action(&#039;wp_print_scripts&#039;,&#039;load_json_parser&#039;);

function load_json_parser(){

	if (is_admin()) return; // probably don&#039;t want this on admin pages

	wp_enqueue_script(&#039;json2&#039;);

}
</pre>
<p>No need any more to play around with eval in the javaScript, but again, this is a WordPress >= 2.9 thing&#8230;. </p>
<h3>3. Borrowing the Text Editor</h3>
<p>Lastly, there is one more, slightly unofficial, dodge that can be used. WordPress makes use of TinyMCE as its rich text editor and this comes with the its own JSON parser. Results may not be completely predictable. </p>
<pre class="brush: php">
require_once(ABSPATH.&quot;/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php&quot;);

$jsObj = new Moxiecode_JSON();

// encodes the supplied array to JSON format
$json = $jsObj-&gt;encode(array(&quot;key1&quot;=&gt;&quot;value1&quot;,&quot;key2&quot;=&gt;&quot;value2&quot;));

//decodes supplied JSON to a PHP array
$json_array = $jsObj-&gt;decode($json);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2010/02/json-wordpress/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Separate Pingbacks from User Comments</title>
		<link>http://themocracy.com/2010/02/separate-pingbacks-user-comments/</link>
		<comments>http://themocracy.com/2010/02/separate-pingbacks-user-comments/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 07:29:21 +0000</pubDate>
		<dc:creator>Lisa</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=256</guid>
		<description><![CDATA[People have predicted their death for a long time, but pingbacks/trackbacks (and displaying them) are still firmly with us - there is a certain vanity involved...

They do give an indication of related content, other sites in your niche (and just how many automated spam sites there are out there ) etc. At the same time, they break up the flow of user comments and even with threaded comments can make it difficult for visitors to follow the discussion. ]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fthemocracy.com%2F2010%2F02%2Fseparate-pingbacks-user-comments%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fthemocracy.com%2F2010%2F02%2Fseparate-pingbacks-user-comments%2F" height="61" width="51" /></a></div><p><img class="alignright size-full wp-image-240" title="wordpress comments" src="http://themocracy.com/wp-content/uploads/2010/02/comments.gif" alt="wordpress comments" width="128" height="128" />People have predicted their death for a long time, but pingbacks/trackbacks (and displaying them) are still firmly with us &#8211; there is a certain vanity involved&#8230;</p>
<p>They do give an indication of related content, other sites in your niche (and just how many automated spam sites there are out there ) etc. At the same time, they break up the flow of user comments and even with threaded comments can make it difficult for visitors to follow the discussion.<br />
<span id="more-256"></span><br />
So it&#8217;s reasonable to separate out pingbacks and perhaps not include their digest content, just the title and a link. The method has changed for WordPress 2.7 upwards, with the arrival of threaded comments and their integration into the core code.</p>
<p>The frist step is to adjust the call to the comments template in <strong>single.php</strong> or where ever you&#8217;re hoping to display the comments&#8230; Replace:</p>
<pre class="brush: php">
&lt;?php comments_template(); ?&gt;
</pre>
<p>with</p>
<pre class="brush: php">
&lt;?php comments_template(&#039;&#039;, true); ?&gt;
</pre>
<p>The &#8220;true&#8221; flag gives access to an array $comments_by_type &#8211; as the name might even suggest, a record of the numbers of each type of comment for that post.</p>
<p>Your theme will (should) have something like this code in it &#8211; most likely in <strong>comments.php</strong> but possibly as a separate comments template function in <strong>functions.php</strong> or elsewhere &#8211; the important thing is to locate <strong>comments_number()</strong> and <strong>wp_list_comments()</strong></p>
<pre class="brush: php">
&lt;h3 id=&quot;comments&quot;&gt;&lt;?php comments_number(&#039;No Responses&#039;, &#039;One Response&#039;, &#039;% Responses&#039; );?&gt; to &amp;#8220;&lt;?php the_title(); ?&gt;&amp;#8221;&lt;/h3&gt;

&lt;ol class=&quot;commentlist&quot;&gt;
&lt;?php wp_list_comments(); ?&gt;
&lt;/ol&gt;
</pre>
<p>Replace it with this:</p>
<pre class="brush: php">

&lt;?php if ( !empty($comments_by_type[&#039;comment&#039;]) ) : ?&gt;

&lt;h3 id=&quot;comments&quot;&gt;&lt;?php comments_number(&#039;No Responses&#039;, &#039;One Response&#039;, &#039;% Responses&#039; );?&gt; to &amp;#8220;&lt;?php the_title(); ?&gt;&amp;#8221;&lt;/h3&gt;

&lt;ol class=&quot;commentlist&quot;&gt;
&lt;?php wp_list_comments(&#039;type=comment&#039;); ?&gt;
&lt;/ol&gt;

&lt;?php endif; ?&gt;

&lt;?php if ( ! empty($comments_by_type[&#039;pings&#039;]) ) : ?&gt;

&lt;h3 id=&quot;pings&quot;&gt;Trackbacks/Pingbacks&lt;/h3&gt;
&lt;ol class=&quot;commentlist&quot;&gt;
&lt;?php wp_list_comments(&#039;type=pings&#039;); ?&gt;
&lt;/ol&gt;

&lt;?php endif; ?&gt;
</pre>
<p>We have 2 lists now, created by wp_list_comments</p>
<p>The other (optional) issue is to recalculate the headline figure of comments &#8211; which is still showing the total of user comments + pings. This is done with the use of the <strong>get_comments_number</strong> filter. Add, in functions.php</p>
<pre class="brush: php">
&lt;?php

add_filter(&#039;get_comments_number&#039;, &#039;comment_count&#039;, 0);
function comment_count( $count ) {
if ( ! is_admin() ) {
global $id;
$comments_by_type = &amp;separate_comments(get_comments(&#039;status=approve&amp;post_id=&#039; . $id));
return count($comments_by_type[&#039;comment&#039;]);
} else {
return $count;
}
}
?&gt;
</pre>
<p>And that should be that &#8211; next step would be to restyle the two lists, with a customized callback function for <strong>wp_list_comments()</strong> &#8211; but that will have to be for another post&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2010/02/separate-pingbacks-user-comments/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A jQuery Slideshow for WordPress 2.9</title>
		<link>http://themocracy.com/2010/02/jquery-slideshow-wordpress/</link>
		<comments>http://themocracy.com/2010/02/jquery-slideshow-wordpress/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 11:03:46 +0000</pubDate>
		<dc:creator>Lisa</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[thumbnails]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=248</guid>
		<description><![CDATA[You want a jQuery slideshow for your WordPress blog? - on the front page, or maybe in the sidebar? No real problem, all the javascript is taken of with the help of a jQuery plugin, all we have to do is figure out how to get the post data. 

And to keep things really simple, this is going to use the thumbnail functions in WP 2.9 - no need to mess around with custom fields any more. ]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fthemocracy.com%2F2010%2F02%2Fjquery-slideshow-wordpress%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fthemocracy.com%2F2010%2F02%2Fjquery-slideshow-wordpress%2F" height="61" width="51" /></a></div><p><img class="alignright size-medium wp-image-249" title="jquery-slideshow" src="http://themocracy.com/wp-content/uploads/2010/02/jquery-slideshow-300x206.gif" alt="jquery slideshow" width="245" height="168" /><strong>You want a jQuery slideshow for your WordPress blog? </strong>- on the front page, or maybe in the sidebar? No real problem, all the javascript is taken of with the help of a jQuery plugin, all we have to do is figure out how to get the post data.</p>
<p>And to keep things really simple, this is going to use the thumbnail functions in WP 2.9 &#8211; no need to mess around with custom fields any more.<br />
<span id="more-248"></span><br />
Firstly, you do have to explicitly declare the new thumbnail system in <strong>functions.php</strong> &#8211; and best to wrap it up in an &#8220;if function exists&#8221; to avoid problems for older WP installs.</p>
<pre class="brush: php">
if (function_exists(&#039;add_theme_support&#039;)) {
add_theme_support( &#039;post-thumbnails&#039; );
add_image_size(&#039;slideshow-image&#039;, 300, 160); // for front page slideshow
}
</pre>
<p>The smart move is to define a &#8220;Featured&#8221; category &#8211; any post in that category will be available for the slideshow, and that&#8217;s the selection taken care of. Create a category &#8211; call it featured, or anything, but make a note of the cat_ID &#8211; mouseover a category on the admin categories page and it&#8217;ll be in the url, something like:</p>
<blockquote><p>http://testblog.com/wp-admin/categories.php?action=edit&#038;<strong>cat_ID=3</strong></p></blockquote>
<p>The ordering will be by date, newest first. (Don&#8217;t forget you can tweak the timestamp of a post if you really want to just to get the order exactly as you want it).</p>
<p>So create a couple of posts in this category and add some thumbnails to them &#8211; since our slideshow is going to be 300px by 160px, make sure they&#8217;re bigger than that. Then, in <strong>home.php</strong>, or <strong>index.php</strong>, where ever you want the slideshow to appear, add:</p>
<pre class="brush: php">
&lt;?php

$featured_category_id = 3;
$number_of_posts = 4;

$args = array(&#039;showposts&#039;=&gt;$number_of_posts, &#039;cat&#039;=&gt;$featured_category_id);

$slideshow_query = new WP_Query($args);

?&gt;
&lt;div id=&quot;slideshow&quot;&gt;
&lt;?php
// let&#039;s keep a record of the post IDs as we go, in case we want to omit these from other post loops/lists on the same page
$duplicates = array();

while ($slideshow_query-&gt;have_posts()) : $slideshow_query-&gt;the_post();

//add the ID to the duplicates array for future reference
$duplicates[] = $id;

//test to see whether there&#039;s a thumbnail associated with the post
if (has_post_thumbnail()) {
?&gt;
&lt;div class=&quot;post-thumbnail&quot;&gt;
&lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot;&gt;
&lt;?php	the_post_thumbnail(&#039;slideshow-image&#039;); ?&gt;
&lt;/a&gt;
&lt;/div&gt;
&lt;?php	}
endwhile;
?&gt;
&lt;/div&gt;  &lt;!-- end of #slideshow --&gt;
</pre>
<p>Next, some javascript. We can use the excellent <a href="http://malsup.com/jquery/cycle/">jQuery Cycle Plugin</a> &#8211; as the package stands currently, we&#8217;ll use <strong>jquery.cycle.all.min.js</strong> &#8211; which allows all the possible transition effects etc. &#8211; in practice, you may well want to use the lighter versions&#8230;</p>
<p>* For a standard production site, always use <strong>min</strong> = minified,  rather than <strong>pack</strong> = packed &#8211; pack may be a smaller filesize, but it doesn&#8217;t run quicker&#8230;.</p>
<p>We need a very quick script to configure and activate the plugin &#8211; so create a new file, <strong>slideshow-activate.js</strong></p>
<pre class="brush: js">
jQuery(document).ready(function($){
$(&#039;#slideshow&#039;).cycle({
fx: &#039;fade&#039; // choose your transition type, ex: fade, scrollUp, shuffle, etc...
});
});
</pre>
<p>Later, there are lots of options here, transition speed, pausing etc. &#8211; consult the <a href="http://malsup.com/jquery/cycle/browser.html">plugin pages</a> for ideas.</p>
<p>We need to get our scripts on the WordPress page, and indicate that they depend on jQuery being loaded &#8211; making use of the WordPress functions <strong>wp_register_script</strong> and <strong>wp_enqueue_script</strong> &#8211; so in <strong>functions.php</strong></p>
<pre class="brush: php">

add_action(&#039;wp&#039;, &#039;js_head_load&#039;);

function js_head_load(){

if(is_admin()) return;  //so that we&#039;re not loading unecessary scripts in the admin

wp_register_script(&#039;cycle&#039;, get_bloginfo(&#039;template_directory&#039;)  . &#039;/scripts/jquery.cycle.all.min.js&#039;, array(&#039;jquery&#039;), &#039;1.0&#039;);

wp_enqueue_script(&#039;slideshow-activate&#039;,  get_bloginfo(&#039;template_directory&#039;)  . &#039;/scripts/slideshow-activate.js&#039;, array(&#039;jquery&#039;, &#039;cycle&#039;), &#039;1.0&#039;);

}
</pre>
<p>And then, don&#8217;t forget to put the 2 files into /scripts in your theme folder&#8230;</p>
<p>That should give you a working slideshow &#8211; ready to be styled with some CSS. Note that the way the Cycle plugin works is that it looks to rotate the immediate children of the div being called &#8211; here, they&#8217;re images, they could be eg. divs &#8211; so if you add a wrapper div(s) you may need to adjust slideshow-activate.js.</p>
<p>And if it&#8217;s not working, check first that the right scripts (jQuery, Cycle, slideshow-activate) are actually being loaded and in the right order, by looking at the page source &#8211; and check you&#8217;ve got thumbnails attached to the relevant posts&#8230;</p>
<p>You could go on to tidy this up &#8211; avoiding the hard-coded category id by having something in the theme options admin to change the id for example. Also, as said earlier, there&#8217;s a lot of scope in playing with the plugin parameters to get exactly the slideshow you want&#8230;</p>
<p>Lastly &#8211; the record of the duplicates we kept &#8211; the method for omitting them from subsequent Loops of posts is here: <a href="http://themocracy.com/2010/01/multiple-wordpress-queries-duplicates/">Multiple WordPress query duplicates</a></p>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2010/02/jquery-slideshow-wordpress/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>WordPress Action Hooks &#8211; the simplified version</title>
		<link>http://themocracy.com/2010/02/wordpress-action-hooks-the-simplified-version/</link>
		<comments>http://themocracy.com/2010/02/wordpress-action-hooks-the-simplified-version/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 09:09:01 +0000</pubDate>
		<dc:creator>Lisa</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=237</guid>
		<description><![CDATA[WordPress action hooks allow you to access the functions of the core WP code, without messing around with that code. It's the basis for most plugins (the whole business essentially started out as the plugin API), but themes are using them more and more and there's no reason not to...

do_action/add_action are also the means of getting external scripts, CSS, javascript/jQuery correctly on the page.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fthemocracy.com%2F2010%2F02%2Fwordpress-action-hooks-the-simplified-version%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fthemocracy.com%2F2010%2F02%2Fwordpress-action-hooks-the-simplified-version%2F" height="61" width="51" /></a></div><p><strong>There&#8217;s no point in hacking around with the WordPress core code.</strong> You still see people doing it sometimes and happily showing off their results, but it just isn&#8217;t a good idea. Nobody else can use it without making the same hack(s), which aren&#8217;t carried through an automatic update anyway. </p>
<p>WordPress action hooks allow you to access the functions of the core WP code, without messing around with that code. It&#8217;s the basis for most plugins (the whole business essentially started out as the plugin API), but themes are using them more and more and there&#8217;s no reason not to&#8230; <strong>do_action/add_action are also the means of getting external scripts, CSS, javascript/jQuery correctly on the page.</strong><br />
<span id="more-237"></span><br />
WordPress pre-dates PHP5 and the improvements available in terms of Object-Orientated Programming (OOP). So, while there are obviously classes and objects in there, everything has a flow &#8211; once the PHP engine has compiled the code, it&#8217;s run from top to bottom &#8211; it&#8217;s procedural, as they say. </p>
<p>Instead of adding a method to a class, or extending a class with another class, there are points in the action where the possibility of doing something is left open &#8211; <strong>action hooks</strong> &#8211; either predefined, because they&#8217;ve been put in the core code, or you can create your own.</p>
<p>The means of doing it involve a couple of functions&#8230;   </p>
<h3>do_action() and add_action()</h3>
<p>Simply, <strong>do_action()</strong> is the function to create an action hook.</p>
<p>Whereas <strong>add_action()</strong> is tacking actions onto a given hook and always refers to a function that will called at that point.</p>
<pre class="brush: php">

&lt;?php do_action( $tag, $arg ); ?&gt;

&lt;?php add_action( $tag, $function_to_add, $priority, $accepted_args ); ?&gt;
</pre>
<p>The $tag is the action hook itself, a description of &#8220;where&#8221; &#8211; at what point in the action&#8230;</p>
<p>As an example, we can create an action hook that outputs some content on the home page just before the Loop of posts is output. </p>
<p>so in <strong>home.php</strong></p>
<pre class="brush: php">
 &lt;?php

 do_action( &#039;before_the_index_loop&#039; ); 

    if (have_posts()) : while (have_posts()) : the_post();
     //etc etc
?&gt;
</pre>
<p>and in <strong>functions.php</strong></p>
<pre class="brush: php">

add_action( &#039;before_the_index_loop&#039;, &#039;my_helloworld_display&#039; );

function my_helloworld_display(){

 echo &quot;&lt;p&gt;This is my hello to the world&lt;/p&gt;&quot;;

}
</pre>
<p>At the point where it reaches the action hook ( &#8216;before_the_index_loop&#8217; ) put there by the do_action, it finds a function (my_helloworld_display) to call and calls it. </p>
<p>(Or you could put this in index.php and test whether it&#8217;s running as the home page by using is_home().) </p>
<h3>Priority</h3>
<p>Everything has an order &#8211; lower to higher &#8211; and if you don&#8217;t specify it, the default value of an action is 10.</p>
<p>So here, as an example, we can add an action earlier in the document flow that&#8217;s actually going to be run <em>after</em> the next add_action.</p>
<pre class="brush: php">

add_action( &#039;my_helloworld&#039;, &#039;my_second_helloworld_display&#039;, 20);
add_action( &#039;my_helloworld&#039;, &#039;my_helloworld_display&#039;);

function my_second_helloworld_display(){
 echo &quot;&lt;p&gt;Hello again to the world&lt;/p&gt;&quot;;
}

function my_helloworld_display(){
 echo &quot;&lt;p&gt;Hello to the world&lt;/p&gt;&quot;;
}
</pre>
<p>Will produce:</p>
<blockquote><p>
Hello to the world<br />
Hello again to the world
</p></blockquote>
<h3>Accepted arguments</h3>
<p>In, say, <strong>header.php</strong>, we can place a hook with some arguments:</p>
<pre class="brush: php">

do_action( &#039;my_details&#039;, get_bloginfo(&#039;name&#039;), get_bloginfo(&#039;description&#039;));
</pre>
<p>While in <strong>functions.php</strong> we&#8217;re going to expect 2 arguments to be passed to the function.</p>
<pre class="brush: php">

add_action( &#039;my_details&#039;, &#039;my_details_display&#039;, 10 ,2);

function my_details_display($name, $description){

 echo &quot;&lt;p&gt;This is the name of my blog: {$name} and this is its description: {$description}&lt;/p&gt;&quot;;
}
</pre>
<p>(Of course, this is just for the very simple example of it, to show how arguments are passed to any function referenced by an add_action &#8211;  the whole process could have been short-cut just by putting bloginfo(&#8216;name&#8217;) on the page&#8230;)</p>
<p>In practice, it can be slightly tricky to find out the what and how many of arguments are being passed to predefined action hooks &#8211; that&#8217;s when you do have to look into the core code.</p>
<p>And just for experiment (on a development site, don&#8217;t leave lying around on anything live)</p>
<pre class="brush: php">

add_action(&#039;wp&#039;, &#039;my_vardump&#039;);

function my_vardump($query){
	global $post;
	print_r($query);
	print_r($post);
}
</pre>
<p>Just to see what&#8217;s available to play with&#8230; </p>
<p>There are a lot of action hooks strewn around the place in WordPress code already &#8211; not all of them are terribly well-documented, (it&#8217;s a large job). The thing to do is to consult first the <a href="http://codex.wordpress.org/Plugin_API/Action_Reference">Codex</a> for the main list of hooks and then experiment, adding your own hooks and making use of those already there. At least, action hooks do simplify the whole process &#8211; it&#8217;s only one line of code to comment out if things start going wrong. </p>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2010/02/wordpress-action-hooks-the-simplified-version/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How&#8217;s Twitter doing these days?</title>
		<link>http://themocracy.com/2010/02/hows-twitter-doing/</link>
		<comments>http://themocracy.com/2010/02/hows-twitter-doing/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 10:52:19 +0000</pubDate>
		<dc:creator>Lisa</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[cotweet]]></category>
		<category><![CDATA[socialoomph]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=235</guid>
		<description><![CDATA[Some thoughts on Twitter and how it affects the average WordPress blogger presently :- how to get value out of it, what to avoid and how to maintain a decent etiquette - it does seem to have grown slightly in the last year or so.

Success requires 2-way communication. "Broadcasters" - you know the ones... Their profile says 3 following 12,455 followers - they're not being a success via Twitter, they're trading off an established reputation.

It would be nice not to have to do the work, but if you're starting at the bottom... you'll have to do the work, no one else will. Follow those who follow you. ]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fthemocracy.com%2F2010%2F02%2Fhows-twitter-doing%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fthemocracy.com%2F2010%2F02%2Fhows-twitter-doing%2F" height="61" width="51" /></a></div><p><img src="http://themocracy.com/wp-content/uploads/2010/02/twitter2.gif" alt="" title="twitter" width="150" height="150" class="alignright size-full wp-image-236" /><strong>Some thoughts on Twitter and how it affects the average WordPress blogger presently</strong> :- how to get value out of it, what to avoid and how to maintain a decent etiquette &#8211; it does seem to have grown slightly in the last year or so.</p>
<p><strong>Success requires 2-way communication</strong>. &#8220;Broadcasters&#8221; &#8211; you know the ones&#8230; Their profile says 3 following 12,455 followers &#8211; they&#8217;re not being a success via Twitter, they&#8217;re trading off an established reputation.</p>
<p>It would be nice not to have to do the work, but if you&#8217;re starting at the bottom&#8230; you&#8217;ll have to do the work, no one else will. Follow those who follow you.<br />
<span id="more-235"></span><br />
<strong>Twitter is networking, linking, creating connections</strong>, so there&#8217;s logic in not just tweeting your own content.<br />
If someone tweets your content tweet about theirs and/or retweet them. People do respond well to being talked up &#8211; shameless, I know, but we are creatures of vanity. Giving someone a positive mention can pay a dividend. You can give them a recommendation at <a href="http://mrtweet.com/home">MrTweet</a> and elsewhere, and there&#8217;s always <strong>#followfriday</strong>.</p>
<p>Note that there are 2 competing factors with retweeting someone else&#8217;s content.</p>
<ol>
<li>You want to keep retweets vaguely accurate to your niche, obviously </li>
<li>But you&#8217;ll want to introduce your followers to someone/something new &#8211; they&#8217;ll think of you as authoritative, god forbid&#8230;</li>
</ol>
<p>Try to keep a handle on what you retweet, it&#8217;s all too easy to get carried away by the urge to fill up the timeline and look busy.  So careful who you recommend and retweet because it all reflects on you. Avoid the gimmicks of you follow me, I&#8217;ll follow you etc etc. looks tacky&#8230;.</p>
<p><strong>And do watch out for shortened urls</strong> &#8211; don&#8217;t display or retweet anything you haven&#8217;t first checked, and that definitely includes anything that arrives in a comment.</p>
<p>The nature of Twitter now is that nobody can read all their tweets &#8211; so a little bit of duplicate tweeting for your own content has its value. Too much and the risk is obvious, so maybe if you&#8217;re tweeting up a new blog post, mention it a couple of times on the day and then again a couple of days later, no great harm in that. Schedule &#8211; a little bit. <a href="http://www.socialoomph.com/">Socialoomph</a>, <a href="http://cotweet.com/">CoTweet</a> and others have the means to schedule your priceless content.</p>
<p>But definitely &#8211; we&#8217;re not always as good at this as we&#8217;d like to be &#8211; make some reply to your @mentions, if they&#8217;re not completely auto-generated. </p>
<p>On the other hand again, it&#8217;s more difficult, and probably not efficient, to keep up with all your direct messages &#8211; far too many of these are auto-generated marketing drivel. So there&#8217;s probably no good reason to DM somebody if you want to make sensible contact &#8211; you might try tweeting an @mention as well to indicate you sent a DM&#8230;  </p>
<p><strong>Don&#8217;t bother to get annoyed if someone makes no response</strong> &#8211; they may be far too busy with other things, they may be grateful but not inclined to fill up their timeline with mutual congratulations, they may be a bit of a tosser. Who knows&#8230; Don&#8217;t take it personally, get on with what&#8217;s next&#8230;</p>
<p>And lastly &#8211; <strong>waste no time on the pointless building of followers</strong>. There are good and bad followers, but the vast majority are meaningless followers. Yes, I know there are a few things around the web that reward huge metrics, but you&#8217;re sending out a tweet that even if noticed is never going to be in the sphere of interest of the noticer &#8211; what&#8217;s the point?</p>
<p>My guess, and that of others, is that Twitter is starting to fight a battle with its signal-to-noise ratio, other options such as FriendFeed seem to have their advantages (for how long&#8230;?) so it is up to you to keep it relevant&#8230; </p>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2010/02/hows-twitter-doing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress 2.9 &#8211; Using Post Thumbnails</title>
		<link>http://themocracy.com/2010/02/wordpress-2-9-using-post-thumbnails/</link>
		<comments>http://themocracy.com/2010/02/wordpress-2-9-using-post-thumbnails/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 11:20:20 +0000</pubDate>
		<dc:creator>Lisa</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[thumbnails]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=229</guid>
		<description><![CDATA[With WordPress 2.9 comes a revised image thumbnail system &#8211; previously, support for posts with attached thumbnails was a little haphazard (it is a fiddly business in terms of the programming), but this is a significant step forward. The need is for a series of images, of given size, associated with a series of posts [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fthemocracy.com%2F2010%2F02%2Fwordpress-2-9-using-post-thumbnails%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fthemocracy.com%2F2010%2F02%2Fwordpress-2-9-using-post-thumbnails%2F" height="61" width="51" /></a></div><p><img src="http://themocracy.com/wp-content/uploads/2010/02/wordpress-admin-thumbnail-widget.png" alt="" title="wordpress-admin-thumbnail-widget" width="307" height="212" class="alignright size-full wp-image-231" /><strong>With WordPress 2.9 comes a revised image thumbnail system</strong> &#8211; previously, support for posts with attached thumbnails was a little haphazard (it is a fiddly business in terms of the programming), but this is a significant step forward.</p>
<p>The need is for a series of images, of given size, associated with a series of posts &#8211; maybe for a front page with post excerpts and their images, or for a featured posts slideshow. Before 2.9, every theme developer had a different way of doing it &#8211; some with patent recipes for determining (guessing) which thumbnail was attached to which posts, while other themes required the web admin to add a thumbnail custom meta field manually, a bit tiresome.<br />
<span id="more-229"></span></p>
<h3>add_theme_support()</h3>
<p>Firstly, you do have to explicitly declare the new thumbnail system in <strong>functions.php</strong> &#8211; and best to wrap it up in an &#8220;if function exists&#8221; to avoid problems for older WP installs.</p>
<pre class="brush: php">
// to prevent  WP &lt; 2.9 breaking
if (function_exists(&#039;add_theme_support&#039;)) {
add_theme_support( &#039;post-thumbnails&#039; );
}
</pre>
<p>This produces a whole new little widget on admin post edit pages. In terms of admin, you can now attach a thumbnail image to a post using this widget, (or by adding an image via the media gallery, as before), and then taking the &#8220;Use as thumbnail&#8221; option<br />
<img src="http://themocracy.com/wp-content/uploads/2010/02/wordpress-admin-add-thumbnail.png" alt="" title="wordpress-admin-add-thumbnail" width="477" height="110" class="aligncenter size-full wp-image-230" /></p>
<h3>Usage</h3>
<p>Now, you have the <strong>has_post_thumbnail()</strong> and <strong>the_post_thumbnail()</strong> template tags available &#8211; so in the post loop,  say for <strong>home.php</strong></p>
<pre class="brush: php">
&lt;?php if ( has_post_thumbnail()) { ?&gt;

	&lt;div class=&quot;thumbnail&quot;&gt;
		&lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot;&gt;
		&lt;?php the_post_thumbnail(); ?&gt;&lt;/a&gt;
	&lt;/div&gt;

 &lt;?php	} ?&gt;
</pre>
<p><strong> has_post_thumbnail()</strong> tests whether a thumbnail exists for the post &#8211; if so, go on to display it with <strong>the_post_thumbnail()</strong>. You could also add an else here and go to display a default image if there isn&#8217;t a thumbnail</p>
<p>So far so good &#8211; but what size are the thumbnails going to be?</p>
<h3>Sizing Thumbnails</h3>
<p>This is where the complications arrive &#8211; but the good news there&#8217;s now various ways to control the whole system, giving you a better chance of getting what you want, fairly painlessly&#8230; There&#8217;s 3 main ways of doing it.</p>
<p>First, you can specify the image dimensions directly as variables in the template tag</p>
<pre class="brush: php">
	the_post_thumbnail(array(150,90));
</pre>
<p>Note that the variable is an array. This method is fine enough if the theme is simply using one size of thumbnail &#8211; it does give some odd results if you start elaborating, with different sizes on different pages, so&#8230; </p>
<p>Secondly, back in <strong>functions.php</strong></p>
<pre class="brush: php">
if (function_exists(&#039;add_theme_support&#039;)) {
add_theme_support(&#039;post-thumbnails&#039;);
set_post_thumbnail_size(150, 90, true);
}
</pre>
<p>The set_post_thumbnail_size gives a default, here 150px width, 90px height &#8211; the 3rd variable is the &#8220;hard-crop&#8221; flag mode. 2 ways to go here, box-resizing (flag= false) and hard-cropping (flag=true).</p>
<p><strong>Box resizing </strong> = shrinks an image until it fits the width or height value you&#8217;ve specified. So with this method, you always get the whole image in the thumbnails, but the thumbnails themselves might turn out to be different sizes, width or height.</p>
<p><strong>Hard-cropping</strong> = the image is cropped to match the aspect ratio &#8211; width : height &#8211; and then shrunk to fit. So here you get all thumbnails the same size, but they may be missing cropped parts top/bottom or left/right. In practice, for general theme development, this is usually the best way to go.</p>
<p>Thirdly for sizing, you can use <strong>add_image_size()</strong></p>
<pre class="brush: php">
if (function_exists(&#039;add_theme_support&#039;)) {
	add_theme_support( &#039;post-thumbnails&#039; );
	set_post_thumbnail_size( 150, 90, true ); // default thumbnail size
	add_image_size(&#039;index-thumbnail&#039;, 120, 75); // for front page thumbnails
	add_image_size(&#039;single-post-thumbnail&#039;, 300, 180); // a different thumbnail size on single post pages
}
</pre>
<p>Now, you&#8217;ve done all the hard work and can be used very simply like this:</p>
<pre class="brush: php">
	&lt;?php the_post_thumbnail(&#039;index-thumbnail&#039;); ?&gt;
</pre>
<p>Here, you have the most control over what&#8217;s going on.</p>
<p>I suspect there may be one or two refinements in the pipeline, but these methods have made it much easier to handle thumbnails in themes &#8211; not least you won&#8217;t have to show users how to add custom fields manually. Good effort&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2010/02/wordpress-2-9-using-post-thumbnails/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>WordPress SEO &#8211; the Post Title</title>
		<link>http://themocracy.com/2010/01/wordpress-seo-the-post-title/</link>
		<comments>http://themocracy.com/2010/01/wordpress-seo-the-post-title/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 17:23:37 +0000</pubDate>
		<dc:creator>Lisa</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[marketing]]></category>
		<category><![CDATA[seo]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=211</guid>
		<description><![CDATA[The one thing you have instant control over is the post title - and, usefully, this can make a huge difference, far out of proportion to any time and effort spent in other SEO directions.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fthemocracy.com%2F2010%2F01%2Fwordpress-seo-the-post-title%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fthemocracy.com%2F2010%2F01%2Fwordpress-seo-the-post-title%2F" height="61" width="51" /></a></div><p><img class="alignright size-full wp-image-212" title="seo-strategy" src="http://themocracy.com/wp-content/uploads/2010/01/seo-strategy.jpg" alt="" width="203" height="157" /><strong>First up, the one thing to say as far as SEO is concerned, WordPress runs fine out of the box</strong> &#8211; provided the theme you&#8217;re using isn&#8217;t doing anything too weird, if you don&#8217;t want to get involved in the more structural on-site SEO, there&#8217;s really no great need. </p>
<p>The one thing you have instant control over is the post title &#8211; and, usefully, this can make a huge difference, far out of proportion to any time and effort spent in other SEO directions.<br />
<span id="more-211"></span><br />
Don&#8217;t forget, if you&#8217;ve got pretty permalinks set up on your blog, and there&#8217;s little point in reading further if you haven&#8217;t, these keywords will form the post url and play their part in the search engines&#8217; algorithms.</p>
<p>So here&#8217;s a title:</p>
<p><strong>SEO for WordPress</strong> &#8211; which&#8217;ll do well enough, but you aren&#8217;t going to be on the front page for that search phrase, you haven&#8217;t got any inbound links</p>
<p><strong>WordPress SEO Strategies</strong> &#8211; now you&#8217;re starting to catch the long-tail, competition is less, you&#8217;re more likely to hit the front page of google&#8230;</p>
<p>Never a bad idea to search out likely candidates depending on the context &#8211; &#8220;commercial&#8221;, &#8220;marketing&#8221;, &#8220;free&#8221;, even &#8220;new&#8221;,  etc etc.<br />
One extremely useful free tool for this is <a rel="nofollow" href="https://adwords.google.com/select/KeywordToolExternal">https://adwords.google.com/select/KeywordToolExternal</a></p>
<p><strong>How I learned to stop worrying about WordPress SEO and produced a Successful Blog because of it</strong> &#8211;  trying to catch too many keywords, the impact is diluted&#8230; If there&#8217;s one guiding principle in SEO, it&#8217;s&#8230;</p>
<blockquote><p>Not too little, but definitely not too much.</p></blockquote>
<p>Here, it&#8217;s a good tip to remove the pointless the&#8217;s, a&#8217;s (stopwords in search engine talk) from the permalink before publication &#8211; it&#8217;s going to bring a slight dividend. Note the difference between post title and permalink on this post.</p>
<p>And lastly, if you&#8217;re planning a trip to Digg or Stumbleupon for some link-baiting then you&#8217;ll want to be catching the eye, and it&#8217;s the shallow mentality that works so well in Digg etc in propagating a meme &#8211; so when you launch the story on any of these sites, change the title when prompted&#8230;</p>
<p><strong>WordPress SEO with added Bikini Blondes</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2010/01/wordpress-seo-the-post-title/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

