<?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 Do&#039;s &#38; Don&#039;ts &#187; Blog</title>
	<atom:link href="http://webdosanddonts.com/category/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://webdosanddonts.com</link>
	<description>Tips&#38;Tricks for the modern day web designer</description>
	<lastBuildDate>Sun, 07 Mar 2010 20:43:14 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to count posts in multiple categories for Wordpress</title>
		<link>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress</link>
		<comments>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress#comments</comments>
		<pubDate>Sun, 29 Nov 2009 16:14:58 +0000</pubDate>
		<dc:creator>Siniša</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://webdosanddonts.com/?p=581</guid>
		<description><![CDATA[As we promised in WebD&#38;D v2 introductory article, we&#8217;re doing a little series of articles about custom Wordpress stuff we did to achieve certain features here on WebD&#38;D. So here is the first one of the series&#8230;
One of the things that we needed throughout the site was a count of posts within various combinations of [...]]]></description>
			<content:encoded><![CDATA[<p>As we promised in <a href="/introducing-webdd-version-two">WebD&amp;D v2 introductory article</a>, we&#8217;re doing a little series of articles about custom Wordpress stuff we did to achieve certain features here on WebD&amp;D. So here is the first one of the series&#8230;<span id="more-581"></span></p>
<p>One of the things that we needed throughout the site was a count of posts within various combinations of categories. Unfortunately, that kind of feature isn&#8217;t supported in Wordpress out-of-the-box. We&#8217;ll get a little technical here so those of you who just want the final solution&#8211;feel free to fast forward to the end of the article and grab the code.</p>
<h2>How we did it</h2>
<p>Wordpress is, as you probably know, a database driven platform, so first thing we need to do is to identify the right <a title="Wordpress database diagram" href="http://codex.wordpress.org/File:WP_27_dbsERD.png">tables and understand their relationships</a> in order to retrieve the correct data from them.</p>
<p>Basically our goal here is to identify terms that have taxonomy <em>&#8216;category&#8217;</em> and filter the ones we&#8217;re interested in. For filtering only specific categories well need to join <em>terms</em> table. Then we have to find out which posts belong to those categories. That&#8217;s why we&#8217;ll join the <em>wp_term_relationships</em> table. And last but not least, we&#8217;ll throw <em>posts</em> table to the mix.</p>
<p>Let&#8217;s say we wanted to count all posts from &#8220;Advanced&#8221; and &#8220;Intermediate&#8221; categories. Assuming that table prefix is the default one, our SQL query should look something like:</p>
<pre><code>SELECT	COUNT( DISTINCT cat_posts.ID ) AS post_count
FROM 	wp_term_taxonomy AS cat_term_taxonomy INNER JOIN wp_terms AS cat_terms ON
		cat_term_taxonomy.term_id = cat_terms.term_id
	INNER JOIN wp_term_relationships AS cat_term_relationships ON
		cat_term_taxonomy.term_taxonomy_id = cat_term_relationships.term_taxonomy_id
	INNER JOIN wp_posts AS cat_posts ON
		cat_term_relationships.object_id = cat_posts.ID
WHERE 	cat_posts.post_status = 'publish' AND
	cat_posts.post_type = 'post' AND
	cat_term_taxonomy.taxonomy = 'category' AND
	cat_terms.slug IN ('advanced', 'intermediate')</code></pre>
<p>The name of the <em>posts</em> table is somewhat misleading because it contains not only posts but pages, post revisions, and whatnot&#8230; Hence the condition <code>post_type = 'post'</code>. Being picky like we are, we only want published posts so we expanded our condition with a little <code>post_status = 'publish'</code>.</p>
<p>Another thing I want to point out is the <code>COUNT DISTINCT</code>&#8230; A well know feature in Wordpress is that a post can belong to any number of categories so without counting only distinct post IDs we could end up with a wrong (much bigger) count.</p>
<p>Now we&#8217;ll change that query a bit and wrap it in a PHP function. That will allow us to pass any number of category slugs.</p>
<pre><code>function wdd_in_category_count($catslugs = '', $display = true) {
	global $wpdb;

	$post_count = 0;
	$slug_where = '';
	$catslugs_arr = split(',', $catslugs);

 	foreach ($catslugs_arr as $catslugkey => $catslug) {
		if ( $catslugkey > 0 ) {
			$slug_where .= ', ';
		 }

 		$slug_where .= "'" . trim($catslug) . "'";
	}

	$slug_where = "cat_terms.slug IN (" . $slug_where . ")";

	$sql =	"SELECT	COUNT( DISTINCT cat_posts.ID ) AS post_count " .
		"FROM 	" . $wpdb->term_taxonomy . " AS cat_term_taxonomy INNER JOIN " . $wpdb->terms . " AS cat_terms ON " .
				"cat_term_taxonomy.term_id = cat_terms.term_id " .
			"INNER JOIN " . $wpdb->term_relationships . " AS cat_term_relationships ON " .
				"cat_term_taxonomy.term_taxonomy_id = cat_term_relationships.term_taxonomy_id " .
			"INNER JOIN " . $wpdb->posts . " AS cat_posts ON " .
				"cat_term_relationships.object_id = cat_posts.ID " .
		"WHERE 	cat_posts.post_status = 'publish' AND " .
			"cat_posts.post_type = 'post' AND " .
			"cat_term_taxonomy.taxonomy = 'category' AND " .
			$slug_where;

	$post_count = $wpdb->get_var($sql);

	if ( $display ) {
		echo $post_count;
	} 

	return $post_count; 

}
</code></pre>
<p>Our little function here has a <code>$catslugs</code> input parameter that expects category slugs in a string separated with commas. We also used <code>$wpdb</code> variables instead of hard coding the table names, witch is always a good practice.</p>
<h2>How can you use it</h2>
<p class="download"><a href="http://webdosanddonts.com/wp-content/uploads/2009/11/wdd_in_category_count.zip">Download Multiple category post counter function for Wordpress</a></p>
<p>First download the code, uncompress and paste it somewhere in your functions.php file. Then find the place in your template file where you want to display number of posts form certain categories and call the <code>wdd_in_category_count()</code> function.</p>
<p>For example, if you had a movie review blog and you wanted to display number of reviews for Horror and SF movies, put something like this:</p>
<pre><code>&lt;p&gt;Total number of Horror and SF reviews: &lt;?php wdd_in_category_count('sf, horror') ?&gt;.&lt;/p&gt;</code></pre>
<p>And there you have it&#8230; That&#8217;s how you count <del datetime="2009-11-29T15:15:21+00:00">sheep</del> posts within multiple categories.</p>
<p>Please reply with your questions, comments and suggestions.</p>
]]></content:encoded>
			<wfw:commentRss>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Introducing WebD&amp;D, version two</title>
		<link>http://webdosanddonts.com/introducing-webdd-version-two</link>
		<comments>http://webdosanddonts.com/introducing-webdd-version-two#comments</comments>
		<pubDate>Sun, 22 Nov 2009 22:19:47 +0000</pubDate>
		<dc:creator>Bojan</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://webdosanddonts.com/?p=746</guid>
		<description><![CDATA[When we started this site in early May, we knew exactly what we wanted&#8211;a super, super simple site with a very usable layout. We&#8217;ve done just that and WebD&#38;D, we&#8217;re happy to say, was a great success. As the site grew in content, we needed to rethink and rebuild and fairly soon we started working [...]]]></description>
			<content:encoded><![CDATA[<p>When we started this site in early May, we knew exactly what we wanted&#8211;a super, super simple site with a very usable layout. We&#8217;ve done just that and WebD&amp;D, we&#8217;re happy to say, was <strong>a great success</strong>. As the site grew in content, we needed to rethink and rebuild and fairly soon we started working on version two.</p>
<p>From day one, we also wanted to add a lot of features to the site. With <strong>v2</strong>, we&#8217;re finally introducing some of those new features. We&#8217;ll let you discover those, of which some are not obvious at first glance.</p>
<p>Design-wise, we&#8217;ve not gone far away from version one. What we hope we have done is spice things up a little bit, making the site more visually attractive. We&#8217;ve stuck to the familiar, neutral color scheme and the lovely <a href="http://www.dardenstudio.com/typefaces/omnes">Omnes typeface</a>.</p>
<p>WebD&amp;D is still running on <a title="WordPress - Blog Tool and Publishing Platform" href="http://wordpress.org">WordPress</a>, spiced with some custom made code to achieve exactly what we wanted. The most fun was writing some custom SQL queries for all tag-category combinations and getting variable number of posts (tips and blog) for any category combination. We plan to share the acquired knowledge and experience in future articles. So stay tuned.</p>
<p>We also used some of the sweet plugins available:</p>
<ul>
<li><a title="WP Super Cache" href="http://ocaoimh.ie/wp-super-cache/">WP Super Cache</a></li>
<li><a title="Yet Another Related Posts Plugin" href="http://mitcho.com/code/yarpp/">Yet Another Related Posts Plugin</a></li>
<li><a title="WP-PostRatings" href="http://lesterchan.net/portfolio/programming/php/">WP-PostRatings</a></li>
<li><a title="Twitter for Wordpress" href="http://rick.jinlabs.com/code/twitter">Twitter for Wordpress</a></li>
<li><a title="All in One SEO Pack" href="http://wordpress.org/extend/plugins/all-in-one-seo-pack/">All in One SEO Pack</a></li>
</ul>
<p>This time around, as far as JavaScripting goes, we really took advantage of the excellent <a title="jQuery" href="http://jquery.com/">jQuery</a> framework with some cool plugins. In all our laziness we used:</p>
<ul>
<li><a title="TableSorter" href="http://tablesorter.com/docs/">TableSorter</a></li>
<li><a title="ColorBox" href="http://colorpowered.com/colorbox/">ColorBox</a></li>
</ul>
<p>We don&#8217;t want to keep you away from browsing the site a second longer. We hope you enjoy <strong>WebD&#038;D v2</strong>. Let us know what you think in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://webdosanddonts.com/introducing-webdd-version-two/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>15 Twitter Netiquette Rules You Must Know</title>
		<link>http://webdosanddonts.com/15-twitter-netiquette-rules-you-must-know</link>
		<comments>http://webdosanddonts.com/15-twitter-netiquette-rules-you-must-know#comments</comments>
		<pubDate>Tue, 25 Aug 2009 11:07:21 +0000</pubDate>
		<dc:creator>Bojan</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://webdosanddonts.com/?p=572</guid>
		<description><![CDATA[Whether you are familiar with Twitter or you are just starting to learn what a great networking tool it is, you must get to know how it really works to communicate well and make use of its potential. People use Twitter for many things, but the same rules apply for everyone. Misuse and abuse of [...]]]></description>
			<content:encoded><![CDATA[<p>Whether you are familiar with Twitter or you are just starting to learn what a great networking tool it is, you must get to know how it <strong>really</strong> works to communicate well and make use of its potential. People use Twitter for many things, but the same rules apply for everyone. Misuse and abuse of Twitter is not at all uncommon and even the experienced twitterers often don&#8217;t follow the <strong>netiquette</strong>.</p>
<p>Here are <strong>15 tips</strong> on how to tweet politely and avoid getting <strong>unfollowed</strong>.<span id="more-572"></span></p>
<h2>1. Provide your name, avatar and a short bio</h2>
<p>Always include your name and a short bio in your Twitter profile. People want to know <strong>who you are</strong>. Do not hide behind false names. Be honest if you expect honesty. Make sure to use your photo or a custom avatar so others can remember and recognize you.</p>
<h2>2. Be social</h2>
<p><strong>Be social</strong> and <strong>interact</strong>. Make your tweets personal and let your followers get to know you. Kindly reply if someone asks you a question. Feel free to ask questions zourself and connect with people. Share interesting links with the community (but be sure to check they actually work). After all, Twitter is a <strong>social network</strong>. </p>
<h2>3. Be moderate in self-plugging</h2>
<p>There&#8217;s nothing wrong with the occasional self-plug, but don&#8217;t keep a Twitter account just to promote your work. Although many people use Twitter simply to publish site news, that is <strong>not</strong> what Twitter is about. </p>
<h2>4. No auto direct messages, please</h2>
<p>Auto direct messages are a big <strong>no-no</strong>, even if you are just being nice and saying hi to someone who has just started following you. What auto messages are really saying is &#8220;I don&#8217;t have the time to be really polite so I&#8217;ll just send and auto DM to everyone&#8221;. Also, no one is expecting a DM when they start following you. </p>
<h2>5. Give credit</h2>
<p>When you find a useful information somewhere, be it a tweet, a blog post or a picture you want to share, <strong>give credit</strong> by letting people know who it was that led you to your discovery. If you read a tweet you want to share with others, a simple retweet will do. </p>
<p><a href="http://twitter.com/iA/statuses/3526325519"><img src="http://webdosanddonts.com/wp-content/uploads/2009/08/ia-tweet.png" alt="Screenshot of a tweet from iA" width="400" height="191" class="alignnone size-full wp-image-648 post-pic-alt" /></a></p>
<h2>6. Don&#8217;t use twitter for chatting or personal conversation</h2>
<p>Twitter is not an instant messenger. Not only it is not as effective as IM is, but others <strong>don&#8217;t</strong> really want to read through multiple tweets of your personal conversation. Instead of making private conversations public, use <strong>direct messages</strong> (or e-mail or an IM client). </p>
<h2>7. Your post should not span through multiple tweets</h2>
<p>A tweet should contain up to 140 characters. That&#8217;s 140, and not a character more. Don&#8217;t write messages that are <strong>more than one tweet long </strong>and continue your message in the next tweet. Move longer posts to appropriate mediums, like <a href="http://posterous.com/">Posterous</a>, <a href="http://www.tumblr.com/">Tumblr</a>, or your blog.</p>
<h2>8. Don&#8217;t tweet too much</h2>
<p>Twitter is all about <strong>quick and easy messages</strong>. Try not to tweet too much or your followers might not want to read all what you have to say. For me, reading dozens of tweets and retweets a day from a single person is too much. Choose <strong>quality over quantity</strong>. If you suspect you might be tweeting too much, a good idea might be to ask your followers what they think. </p>
<h2>9. Don&#8217;t flood</h2>
<p>While there are people who are interested in reading dozens of your tweets one after the other, most are not. <strong>Flooding</strong> is not polite so try not to overdo it. If your followers have too much to read and explore, they might easily choose to ignore your tweets.</p>
<h2>10. Follow, unfollow and block whoever you wish</h2>
<p>On Twitter, you are free to follow and unfollow whoever you wish. You&#8217;re also free to block people from viewing your tweets. When someone follows you, you are <strong>not obligated</strong> to follow them back. When someone unfollows you, it does not mean you have to unfollow them. Unfollowing someone does not mean &#8220;I don&#8217;t like you&#8221;. </p>
<h2>11. Do not follow everyone who follows you</h2>
<p>Do not follow <strong>everyone</strong> who follows you, just for the sake of it. What good is it to follow thousands of people if you aren&#8217;t really following their tweets? Most users who follow thousands of people are considered to be <strong>spammers</strong>. </p>
<h2>12. Use hashtags, but do not overuse them</h2>
<p><strong>Hashtags</strong> aren&#8217;t really effective if every word in a tweet is a hashtag. Use them <strong>sparingly</strong> to help people find information without making the message look spammy. </p>
<p><a href="http://twitter.com/umutm/status/3532217620"><img src="http://webdosanddonts.com/wp-content/uploads/2009/08/umut-tweet.png" alt="" class="alignnone size-full wp-image-648 post-pic-alt" /></a></p>
<h2>13. Do not spam</h2>
<p><strong>Never spam</strong> on Twitter and do not send people unwanted information. People will unfollow you if you keep asking them to retweet your posts, help you reach a certain number of followers or if you are retweeting contest tweets all of the time. Open a second Twitter account if you like the contests that require retweeting. </p>
<h2>14. Provide enough information</h2>
<p>When you tweet, make sure you provide enough information. Simply copy/pasting an URL is <strong>not enough</strong>. Add value to your tweets and make them <strong>easy to understand and scan</strong>. </p>
<h2>15. Retweet in 140 characters</h2>
<p>Sometimes a retweet will not fit inside the 140 chars limit once you add the @username. To make it fit, <strong>cut the last part </strong>of the message. If you think it will not make a lot of sense like that, change the text but try to keep it as similar to the original as possible. What you are basically doing is quoting someone else, so be fair.</p>
]]></content:encoded>
			<wfw:commentRss>http://webdosanddonts.com/15-twitter-netiquette-rules-you-must-know/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>CushyCMS giweaway winner</title>
		<link>http://webdosanddonts.com/cushy-cms-giweaway-winner</link>
		<comments>http://webdosanddonts.com/cushy-cms-giweaway-winner#comments</comments>
		<pubDate>Tue, 11 Aug 2009 08:34:34 +0000</pubDate>
		<dc:creator>Bojan</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://webdosanddonts.com/?p=562</guid>
		<description><![CDATA[As promised, today we are announcing the winner of the CushyCMS giveaway!
A 12 month subscription to CushyCMS Pro, worth over $330, goes to Spain and Jose Vittone! Congratulations to Jose and thanks to Leigh from Stateless Systems.
Thanks to all the participants, stay tuned for more giveaways on WebD&#038;D.
]]></description>
			<content:encoded><![CDATA[<p>As promised, today we are announcing the winner of the <a href="http://webdosanddonts.com/cushycms-giveaway">CushyCMS giveaway</a>!</p>
<p>A 12 month subscription to <a href="http://www.cushycms.com/">CushyCMS Pro</a>, worth over $330, goes to Spain and <a href="http://josevittone.com/"><strong>Jose Vittone</strong></a>! Congratulations to Jose and thanks to <a href="http://twitter.com/leighhanney">Leigh</a> from <a href="http://www.statelesssystems.com/">Stateless Systems</a>.</p>
<p>Thanks to all the participants, stay tuned for more giveaways on WebD&#038;D.</p>
]]></content:encoded>
			<wfw:commentRss>http://webdosanddonts.com/cushy-cms-giweaway-winner/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CushyCMS giveaway</title>
		<link>http://webdosanddonts.com/cushycms-giveaway</link>
		<comments>http://webdosanddonts.com/cushycms-giveaway#comments</comments>
		<pubDate>Wed, 05 Aug 2009 08:37:18 +0000</pubDate>
		<dc:creator>Bojan</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://webdosanddonts.com/?p=543</guid>
		<description><![CDATA[ Try your luck in our very first giveaway! We&#8217;re giving you an opportunity to win a 12 month subscription to CushyCMS Pro, worth over $330! CushyCMS is a simple content management system powering over 30000 websites. Maybe you&#8217;ll manage your website with it soon as well.
To enter our contest, all you need to do [...]]]></description>
			<content:encoded><![CDATA[<p> Try your luck in our very first <strong>giveaway</strong>! We&#8217;re giving you an opportunity to win a 12 month subscription to <strong><a href="http://www.cushycms.com/">CushyCMS Pro</a></strong>, worth <strong>over $330</strong>! CushyCMS is a simple content management system powering over 30000 websites. Maybe you&#8217;ll manage your website with it soon as well.</p>
<p>To enter our contest, all you need to do is: </p>
<ol>
<li>Post a comment in this post, answering <strong>Why would a free 12 month CushyCMS Pro subscription be cool?</strong>
<li><a href="http://twitter.com/home/?status=RT:+@webdosanddonts+Win+a+Free+CushyCMS+Pro+subscription!+http://tr.im/vxDS">Tweet the CushyCMS giveaway</a></li>
</ol>
<p>The giveaway is open until <strong>August 10, 2009</strong>. We&#8217;ll be chosing the lucky winner with a random generator on <strong>August 11</strong> after which <a href="http://twitter.com/leighhanney">Leigh</a> from <a href="http://www.statelesssystems.com/">Stateless Systems</a> will be providing you with the licence. Best of luck to all of you. </p>
<p>More giveaways will follow so be sure to <a href="http://twitter.com/webdosanddonts/">follow us on Twitter</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://webdosanddonts.com/cushycms-giveaway/feed</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Introducing the WebD&amp;D blog</title>
		<link>http://webdosanddonts.com/introducing-the-webdd-blog</link>
		<comments>http://webdosanddonts.com/introducing-the-webdd-blog#comments</comments>
		<pubDate>Tue, 04 Aug 2009 15:24:39 +0000</pubDate>
		<dc:creator>Bojan</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://webdosanddonts.com/?p=520</guid>
		<description><![CDATA[From today, the WebD&#038;D blog is officially open. Welcome!
On our blog, we&#8217;ll be covering all web design and development related topics. Of course, we&#8217;re also open to any of the suggestions you may have. What would you want us to write about? How would you make our site better? What features would you like to [...]]]></description>
			<content:encoded><![CDATA[<p>From today, the <strong>WebD&#038;D blog</strong> is officially open. Welcome!</p>
<p>On our blog, we&#8217;ll be covering all web design and development related topics. Of course, we&#8217;re also open to any of the suggestions you may have. What would you want us to write about? How would you make our site better? What features would you like to see? As always, you are more than welcome to comment on our site and make your voice count.</p>
<p>We also have a <strong>giveaway</strong> ready for all our readers, so stay tuned and enter the competition soon.</p>
<p>Last, but not least, we&#8217;d like to thank our sponsor, <a href="http://wpwebhost.com/">WPWebHost</a>, because it&#8217;s the sponsors that keep WebD&#038;D alive. </p>
]]></content:encoded>
			<wfw:commentRss>http://webdosanddonts.com/introducing-the-webdd-blog/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
