<?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>Dimuthu's Blog &#187; wordpress</title>
	<atom:link href="http://www.dimuthu.org/catagory/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dimuthu.org</link>
	<description>Waiting for your comments</description>
	<lastBuildDate>Wed, 07 Jul 2010 12:42:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<image>
  <link>http://www.dimuthu.org</link>
  <url>http://www.dimuthu.org/favicon.ico</url>
  <title>Dimuthu's Blog</title>
</image>
		<item>
		<title>WordPress Database &#8211; Relationship with Tags, Catagories and Posts</title>
		<link>http://www.dimuthu.org/blog/2008/12/20/wordpress-database-relationship-with-tags-catagories-and-posts/</link>
		<comments>http://www.dimuthu.org/blog/2008/12/20/wordpress-database-relationship-with-tags-catagories-and-posts/#comments</comments>
		<pubDate>Sat, 20 Dec 2008 16:11:39 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[catgoary]]></category>
		<category><![CDATA[posts]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[taxonomy]]></category>
		<category><![CDATA[term]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=825</guid>
		<description><![CDATA[WordPress has a very simple database schema. And it is well documented. You can access the complete description of the wordpress core database from here, http://codex.wordpress.org/Database_Description. Anyway first time I looked at the database I was confused with the term and the term_taxonomy table, why we need two tables for term and taxonomies. In fact [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress has a very simple database schema. And it is well documented. You can access the complete description of the wordpress core database from here, <a href="http://codex.wordpress.org/Database_Description">http://codex.wordpress.org/Database_Description</a>.</p>
<p>Anyway first time I looked at the database I was confused with the term and the term_taxonomy table, why we need two tables for term and taxonomies. In fact in wordpress, the table &#8216;posts&#8217; is associated with the table &#8216;term_taxonomy&#8217; and not the table &#8216;term&#8217; itself. In the term taxonomy table the terms are associated to a link category, post category or a tag. So the associations of posts to a tag or category is something like this.</p>
<div id="attachment_828" class="wp-caption alignnone" style="width: 510px"><a href="http://www.dimuthu.org/wp-content/uploads/2008/12/wp_term_post_association.jpeg"><img class="size-full wp-image-828" title="wp_term_post_association" src="http://www.dimuthu.org/wp-content/uploads/2008/12/wp_term_post_association.jpeg" alt="wp_term_post association" width="500" height="136" /></a><p class="wp-caption-text">wp_term_post association</p></div>
<p>So in a case you try querying for posts with a given tag it will be like this. (Note that I have skipped the optional database table prefix which is by default &#8216;wp_&#8217;)</p>
<pre class="sql"><span style="font-weight: bold; color: #993333;">SELECT</span> post_title,
       post_content,
       post_date
<span style="font-weight: bold; color: #993333;">FROM</span> posts p,
     terms t,
     term_relationships r,
     term_taxonomy tt
<span style="font-weight: bold; color: #993333;">WHERE</span> p.post_status=<span style="color: #ff0000;">'publish'</span> <span style="font-weight: bold; color: #993333;">AND</span>
      tt.taxonomy = <span style="color: #ff0000;">'post_tag'</span> <span style="font-weight: bold; color: #993333;">AND</span>
      p.id=r.object_id <span style="font-weight: bold; color: #993333;">AND</span>
      r.term_taxonomy_id=tt.term_taxonomy_id <span style="font-weight: bold; color: #993333;">AND</span>
      tt.term_id = t.term_id <span style="font-weight: bold; color: #993333;">AND</span> t.name <span style="font-weight: bold; color: #993333;">LIKE</span> ?</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/12/20/wordpress-database-relationship-with-tags-catagories-and-posts/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Write an Adsense Widget for your WordPress Blog on Your Own</title>
		<link>http://www.dimuthu.org/blog/2008/10/17/write-an-adsense-widget-for-your-wordpress-blog-on-your-own/</link>
		<comments>http://www.dimuthu.org/blog/2008/10/17/write-an-adsense-widget-for-your-wordpress-blog-on-your-own/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 20:17:20 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[adsense]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=484</guid>
		<description><![CDATA[It is really easy to write a widget to the wordpress blog. So I thought of writing my own widget to show Google ads in my Blog. Here is how I did it. First generate the JavaScript code for your adsense account from the Google Adsense Page. You can do this by sigining in to [...]]]></description>
			<content:encoded><![CDATA[<p>It is really easy to write a widget to the wordpress blog. So I thought of writing my own widget to show Google ads in my Blog. Here is how I did it.</p>
<ol>
<li>First generate the JavaScript code for your adsense account from the Google Adsense Page. You can do this by sigining in to the Dashboard of Adsense from <a href="https://www.google.com/adsense/">https://www.google.com/adsense/</a>. Then click the &#8220;Adsense Setup&#8221; tab and follow the wizard.</li>
<li>Inside the &#8220;wp-content/plugins&#8221; directory of your WordPress installation create a file for your plugin. (Say myadsense_widget.php)</li>
<li>Then first write the code that should be appeared in your widget.  In this case you can just echo the the code provide by the Google. Anyway In order to make your widget complaint with the current theme, you have to use the code similar to the following.
<pre class="php"><span style="font-style: italic; color: #808080;">// the function for the widget</span>
<span style="font-weight: bold; color: #000000;">function</span> widget_myadsense<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$args</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
	<span style="font-style: italic; color: #808080;">// being aware of the theme</span>
	<a href="http://www.php.net/extract"><span style="color: #000066;">extract</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$args</span><span style="color: #66cc66;">)</span>;
	<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$before_widget</span>;
	<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$before_title</span> . <span style="color: #ff0000;">"Google Adsense"</span>. <span style="color: #0000ff;">$after_title</span>;

	<span style="font-style: italic; color: #808080;">// here you just echo the code provided by the google </span>
	<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> &lt;&lt;&lt;GOOGLE_JS
		&lt;!-- in this space you have to copy paste
                the code provided by the google--&gt;
GOOGLE_JS;

	<span style="font-style: italic; color: #808080;">// again being aware of the theme</span>
	<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$after_widget</span>;
<span style="color: #66cc66;">}</span></pre>
</li>
<li> Then write the code to register the above function as a widget with the following piece of code.
<pre class="php"><span style="font-style: italic; color: #808080;">// initiating widget</span>
<span style="font-weight: bold; color: #000000;">function</span> myadsense_init<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>
<span style="color: #66cc66;">{</span>
	register_sidebar_widget<span style="color: #66cc66;">(</span>__<span style="color: #66cc66;">(</span><span style="color: #ff0000;">'My Adsense'</span><span style="color: #66cc66;">)</span>, <span style="color: #ff0000;">'widget_myadsense'</span><span style="color: #66cc66;">)</span>;
<span style="color: #66cc66;">}</span>

<span style="font-style: italic; color: #808080;">// adding the action</span>
add_action<span style="color: #66cc66;">(</span><span style="color: #ff0000;">"plugins_loaded"</span>, <span style="color: #ff0000;">"myadsense_init"</span><span style="color: #66cc66;">)</span>;</pre>
</li>
<li> We are almost done here, But don&#8217;t forget you can mention your information as the widget plugin author with a  comment similar to the following template.
<pre class="php"><span style="font-style: italic; color: #808080;">/*
Plugin Name: MyAdsense
Plugin URI: http://dimuthu.org
Description: Adsense Plugin for my blog
Author: Dimuthu Gamage
Version: 0.1
Author URI: http://dimuthu.org
*/</span></pre>
</li>
<li> That is all you have to code. Now just go the Plugins section of the wordpress from your Dashboard and enable the plugin (&#8220;myadsesne&#8221;) you just created.</li>
<li> Go to the Design-&gt;Widget section and add your Widget to the Sidebar and click &#8220;Save Changes&#8221;. And go to your blog URL and make sure that the Ads are shown in there.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/10/17/write-an-adsense-widget-for-your-wordpress-blog-on-your-own/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
