<?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>36Flavours.com &#187; WordPress</title>
	<atom:link href="http://36flavours.com/category/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://36flavours.com</link>
	<description>A taste of something different...</description>
	<lastBuildDate>Mon, 19 Apr 2010 20:01:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>WP dbDelta function cannot modify unique keys</title>
		<link>http://36flavours.com/2010/04/wp-dbdelta-function-cannot-modify-unique-keys/</link>
		<comments>http://36flavours.com/2010/04/wp-dbdelta-function-cannot-modify-unique-keys/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 21:12:39 +0000</pubDate>
		<dc:creator>Steve Whiteley</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[dbdelta]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://36flavours.com/?p=685</guid>
		<description><![CDATA[Whilst making some updates to one of my WordPress plugins earlier today, I discovered an small issue when trying to make use of the dbDelta function. Although it&#8217;s advised you avoid creating tables unless absolutely necessary, it seemed like the correct method to store the data used by this particular plugin. This method of storage [...]]]></description>
			<content:encoded><![CDATA[<p class="first">Whilst making some updates to one of my WordPress plugins earlier today, I discovered an small issue when trying to make use of the dbDelta function.</p>
<p>Although it&#8217;s advised you avoid creating tables unless absolutely necessary, it seemed like the correct method to store the data used by this particular plugin.<span id="more-685"></span></p>
<p>This method of storage does have it&#8217;s downsides, especially when it comes to modifying the table structure. Luckily the dbDelta function comes in really handy in aiding the update process.</p>
<p>There is however one issue that I came across, discovering that is unable to modify a unique key (in this situation a composite index).</p>
<p>After browsing through the source code for the dbDelta function I spotted that something was missing. When including an index in the query, it is not dropped before attempting to recreate it and is therefore ignored when performing an update.</p>
<p>Take for example the following code snippet:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-</span>prefix<span style="color: #339933;">.</span><span style="color: #0000ff;">'mytable'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;CREATE TABLE <span style="color: #006699; font-weight: bold;">$table</span> (
	id mediumint(9) NOT NULL AUTO_INCREMENT,
	calendar varchar(255) NOT NULL default 'default',
	year smallint(5) NOT NULL,
	month tinyint(3) NOT NULL,
	day tinyint(3) NOT NULL,
	PRIMARY KEY (id),
	UNIQUE KEY date (year,month,day)
);&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span>ABSPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'wp-admin/includes/upgrade.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dbDelta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>If we make some changes to the SQL statement to add an additional column to the unique index, the index would become something like &#8220;<em>UNIQUE KEY date (year,month,day,calendar)</em>&#8220;.</p>
<p>This will work if the the table does not already exist, but if it attempts to update the table then the changes to the unique key are ignored.</p>
<p>The short and simple solution is to simply check the table exists and then drop the index manually before calling the dbDelta function.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_var</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SHOW TABLES LIKE <span style="color: #006699; font-weight: bold;">$table</span>&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ALTER TABLE <span style="color: #006699; font-weight: bold;">$table</span> DROP INDEX date&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I&#8217;m not sure if this is actually a bug with the function or whether it wasn&#8217;t supposed to allow for updates on indexes in the first place, either way the problem can be quite easily resolved.</p>
]]></content:encoded>
			<wfw:commentRss>http://36flavours.com/2010/04/wp-dbdelta-function-cannot-modify-unique-keys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extend WordPress search to include custom post meta</title>
		<link>http://36flavours.com/2010/03/extend-wordpress-search-to-include-custom-post-meta/</link>
		<comments>http://36flavours.com/2010/03/extend-wordpress-search-to-include-custom-post-meta/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 18:50:24 +0000</pubDate>
		<dc:creator>Steve Whiteley</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[extend]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://36flavours.com/?p=659</guid>
		<description><![CDATA[After receiving numerous requests to allow the SubHeading value in my plugin to be searched when carrying out a default search, I turned my attention to finding a method to achieve this in WordPress 2.9.x. The plugin stores a custom post meta entry for any post or page that requires a subtitle, in order to [...]]]></description>
			<content:encoded><![CDATA[<p class="first">After receiving numerous requests to allow the <a href="http://wordpress.org/extend/plugins/subheading/" target="_self">SubHeading</a> value in my plugin to be searched when carrying out a default search, I turned my attention to finding a method to achieve this in WordPress 2.9.x.</p>
<p>The plugin stores a custom post meta entry for any post or page that requires a subtitle, in order to append this field to the search query I required the use of two actions.<span id="more-659"></span></p>
<ul>
<li>posts_where_request</li>
<li>posts_join_request</li>
</ul>
<p>Each of my plugins use a class based format, so the following examples will be provided in that format. This could quite easily be changed to regular functions</p>
<p>The first action is called when the class is instantiated:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> MyPlugin <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">function</span> MyPlugin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'posts_where_request'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'search'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The first argument passed to this action is a string containing the where clause for the search query.</p>
<p>When the action is called we have also reached a point where we can check whether we are carrying out a blog search &#8220;<strong>is_search()</strong>&#8220;.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> search<span style="color: #009900;">&#40;</span><span style="color: #000088;">$where</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_search<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">,</span> <span style="color: #000088;">$wp</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$where</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">&quot;/\(wp_posts.post_title (LIKE '%<span style="color: #006699; font-weight: bold;">{$wp-&gt;query_vars['s']}</span>%')\)/i&quot;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$0</span> OR (<span style="color: #006699; font-weight: bold;">$wpdb-&gt;postmeta</span>.meta_key = '_mymetakey' AND <span style="color: #006699; font-weight: bold;">$wpdb-&gt;postmeta</span>.meta_value <span style="color: #006699; font-weight: bold;">$1</span>)&quot;</span><span style="color: #339933;">,</span>
			<span style="color: #000088;">$where</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'posts_join_request'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'search_join'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$where</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>All that we do here is include the meta key search by finding the post_title clause and inserting the meta key clause after it, using the preg_replace() function.</p>
<p><em>(Note: I have used the meta key &#8220;_mymetakey&#8221;, you will need to replace this with the key matching your custom meta data.)</em></p>
<p>The where condition is now in place, but we will need to add on the post_meta table, making use of the second action &#8220;posts_join_request&#8221; included in the function above.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> search_join<span style="color: #009900;">&#40;</span><span style="color: #000088;">$join</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$join</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; LEFT JOIN <span style="color: #006699; font-weight: bold;">$wpdb-&gt;postmeta</span> ON (<span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.ID = <span style="color: #006699; font-weight: bold;">$wpdb-&gt;postmeta</span>.post_id) &quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Putting all the basic functionality together you will have something along the lines of this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> MyPlugin <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">function</span> MyPlugin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'posts_where_request'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'search'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">function</span> search<span style="color: #009900;">&#40;</span><span style="color: #000088;">$where</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_search<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">,</span> <span style="color: #000088;">$wp</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$where</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span>
				<span style="color: #0000ff;">&quot;/\(wp_posts.post_title (LIKE '%<span style="color: #006699; font-weight: bold;">{$wp-&gt;query_vars['s']}</span>%')\)/i&quot;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$0</span> OR (<span style="color: #006699; font-weight: bold;">$wpdb-&gt;postmeta</span>.meta_key = '_<span style="color: #006699; font-weight: bold;">{$this-&gt;tag}</span>' AND <span style="color: #006699; font-weight: bold;">$wpdb-&gt;postmeta</span>.meta_value <span style="color: #006699; font-weight: bold;">$1</span>)&quot;</span><span style="color: #339933;">,</span>
				<span style="color: #000088;">$where</span>
			<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'posts_join_request'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'search_join'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$where</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">function</span> search_join<span style="color: #009900;">&#40;</span><span style="color: #000088;">$join</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$join</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; LEFT JOIN <span style="color: #006699; font-weight: bold;">$wpdb-&gt;postmeta</span> ON (<span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.ID = <span style="color: #006699; font-weight: bold;">$wpdb-&gt;postmeta</span>.post_id) &quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>There are however a few possible pitfalls that I have yet to address, the main one being that the meta_value field is not indexed.</p>
<p>I&#8217;m not sure whether to try and automatically add an index to the field or add an additional option on my plugin settings page to create the index.</p>
]]></content:encoded>
			<wfw:commentRss>http://36flavours.com/2010/03/extend-wordpress-search-to-include-custom-post-meta/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress exclude categories from homepage</title>
		<link>http://36flavours.com/2010/01/wordpress-exclude-categories-from-homepage/</link>
		<comments>http://36flavours.com/2010/01/wordpress-exclude-categories-from-homepage/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 19:42:08 +0000</pubDate>
		<dc:creator>Steve Whiteley</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[categories]]></category>
		<category><![CDATA[exclude]]></category>
		<category><![CDATA[posts]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://36flavours.com/?p=592</guid>
		<description><![CDATA[If you use posts within WordPress to generate content, such as Frequently Asked Questions or Help Guides, it&#8217;s quite often the case that you don&#8217;t want these to appear on the posts page of your blog. Instead of having to re-create the whole query, you can append a comma separated list of category ID&#8217;s  that [...]]]></description>
			<content:encoded><![CDATA[<p class="first">If you use posts within <a href="http://wordpress.org/" target="_blank">WordPress</a> to generate content, such as <em>Frequently Asked Questions</em> or <em>Help Guides</em>, it&#8217;s quite often the case that you don&#8217;t want these to appear on the posts page of your blog.</p>
<p>Instead of having to re-create the whole query, you can append a <strong>comma separated list</strong> of category ID&#8217;s  that you want to exclude to the end of the original query and fetch the new data set to be used.<span id="more-592"></span></p>
<p>To achieve this, insert a variation of the following into your index or template file specified as the <strong>posts page</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_home<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> query_posts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$query_string</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;cat=-2,-3'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>This should be placed <strong>before</strong> the loop, therefore ideally just before:</p>

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

<p>Adding this line of code will check if the current page is the posts page (<a href="http://codex.wordpress.org/Conditional_Tags#The_Main_Page" target="_blank">is_home</a>) and if so <strong>exclude</strong> the categories with ID&#8217;s 2 and 3. Note here the <strong>negation</strong> used (-2 and -3), without this the query will include rather than exclude the categories.</p>
<p>If you don&#8217;t want to hard code ID values, you could use the <a href="http://codex.wordpress.org/Function_Reference/get_category_by_slug" target="_blank">get_category_by_slug</a> or <a href="http://codex.wordpress.org/Function_Reference/get_category_by_path" target="_blank">get_category_by_path</a> functions to fetch the category ID.</p>
]]></content:encoded>
			<wfw:commentRss>http://36flavours.com/2010/01/wordpress-exclude-categories-from-homepage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An attempt to write a blog post a day for a whole year</title>
		<link>http://36flavours.com/2009/12/an-attempt-to-write-a-blog-post-a-day-for-a-whole-year/</link>
		<comments>http://36flavours.com/2009/12/an-attempt-to-write-a-blog-post-a-day-for-a-whole-year/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 12:08:18 +0000</pubDate>
		<dc:creator>Steve Whiteley</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[365]]></category>
		<category><![CDATA[challenge]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[year]]></category>

		<guid isPermaLink="false">http://36flavours.com/?p=596</guid>
		<description><![CDATA[Over the past few days I&#8217;ve been setting up a small and simple, yet long term project in which I intend to write at least one blog post a day for entire year, starting with the first post on 1st January 2010. The project preparation started on the 24th December when I registered the domain [...]]]></description>
			<content:encoded><![CDATA[<p class="first">Over the past few days I&#8217;ve been setting up a small and simple, yet long term project in which I intend to write at least one blog post a day for entire year, starting with the first post on 1st January 2010.</p>
<p>The project preparation started on the <strong>24th December</strong> when I registered the domain name <strong><a href="http://yearblog.co.uk" target="_blank">yearblog.co.uk</a></strong> <em>(a little dull, but to the point)</em>. Once that and the hosting side of things were ready I installed the latest version of WordPress (2.9) and began coming up with a few ideas for simple theme.<span id="more-596"></span></p>
<p>My initial ideas surrounded the fact that it was a year long project, so started developing designs that resembled the look and feel of a calendar. I soon got bored of this when I discovered that it was difficult to find content and navigate around, so opted for a more &#8216;traditional&#8217; approach instead.</p>
<p>I released the final theme on the site yesterday and started mentioning the idea of <strong>YearBlog</strong> on <strong><a href="http://twitter.com/36flavours" target="_blank">twitter</a></strong> and to a few friends, who decided that they may like to get in on the act and join me on this journey &#8211; good luck!</p>
<p>Luckily there is a really simple solution for allowing multiple blogs on the same domain <em>(using either sub-domains or sub-directories)</em>, in the form of <a href="http://mu.wordpress.org/" target="_blank">WordPress MU</a>. It didn&#8217;t take long until everything was up and running and I was getting ready to start blogging.</p>
<p>Although the project doesn&#8217;t actually start until the end of the week, I&#8217;ve already written two posts on the subject of preparation. To read more about the project and keep up to date with the progress, head over to my <a href="http://yearblog.co.uk/" target="_blank">YearBlog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://36flavours.com/2009/12/an-attempt-to-write-a-blog-post-a-day-for-a-whole-year/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WP SubHeading Plugin (1,000 downloads)</title>
		<link>http://36flavours.com/2009/11/wp-subheading-plugin-1000-downloads/</link>
		<comments>http://36flavours.com/2009/11/wp-subheading-plugin-1000-downloads/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 11:28:16 +0000</pubDate>
		<dc:creator>Steve Whiteley</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[heading]]></category>
		<category><![CDATA[sub]]></category>
		<category><![CDATA[title]]></category>

		<guid isPermaLink="false">http://36flavours.com/?p=574</guid>
		<description><![CDATA[The WordPress SubHeading plugin allows you to add sub titles to both your blog posts and pages. Last night it followed in the footsteps of my Page Meta plugin by reaching the 1,000 downloads mark. Yesterday saw over 100 downloads as a result of numerous modifications and updates, some of which due to mistakes on [...]]]></description>
			<content:encoded><![CDATA[<p class="first">The <a href="http://wordpress.org/extend/plugins/subheading/" target="_blank">WordPress SubHeading plugin</a> allows you to add sub titles to both your blog posts and pages. Last night it followed in the footsteps of my <a href="http://wordpress.org/extend/plugins/pagemeta/" target="_blank">Page Meta plugin</a> by reaching the <a href="http://wordpress.org/extend/plugins/subheading/stats/" target="_blank">1,000 downloads</a> mark.</p>
<p>Yesterday saw over <strong>100 downloads</strong> as a result of numerous modifications and updates, some of which due to mistakes on my behalf which was mildly irritating. The main reason behind all the updates was to cater for numerous <a href="http://wordpress.org/tags/subheading?forum_id=10" target="_blank">feature requests and bugs</a> reported by users of the plugin.<span id="more-574"></span></p>
<p>This plugin &#8211; as with Page Meta &#8211; was written for a project I have been working on, however there are very few that solve the issue of adding in sub headings / titles and reposition it below the main title (or at least as far as I am aware).</p>
<p>If you have any feedback on this plugin I recommend you post it on the <a href="http://wordpress.org/tags/subheading?forum_id=10" target="_blank">WordPress Plugins forums</a>, otherwise if you&#8217;re looking to install this plugin it can be <a href="http://wordpress.org/extend/plugins/subheading/" target="_blank">downloaded here</a>.</p>
<p style="text-align: center;"><img class="size-full wp-image-579  aligncenter" title="WordPress SubHeading Screenshot" src="http://36flavours.com/wp-content/uploads/2009/11/screenshot-1.png" alt="WordPress SubHeading Screenshot" width="530" height="400" /></p>
]]></content:encoded>
			<wfw:commentRss>http://36flavours.com/2009/11/wp-subheading-plugin-1000-downloads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WP Page Meta Plugin (1,000 downloads)</title>
		<link>http://36flavours.com/2009/11/wp-page-meta-plugin-1000-downloads/</link>
		<comments>http://36flavours.com/2009/11/wp-page-meta-plugin-1000-downloads/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 18:36:59 +0000</pubDate>
		<dc:creator>Steve Whiteley</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[meta]]></category>
		<category><![CDATA[page]]></category>

		<guid isPermaLink="false">http://36flavours.com/?p=556</guid>
		<description><![CDATA[The WordPress Page Meta plugin was initially written as a simple solution for adding meta descriptions to pages on a site I have been working on, as this is not available by default. Today it broke through the 1,000 downloads mark. The plugin quite quickly evolved into a solution that allowed for keywords as well [...]]]></description>
			<content:encoded><![CDATA[<p class="first">The <a href="http://wordpress.org/extend/plugins/pagemeta/" target="_blank">WordPress Page Meta plugin</a> was initially written as a simple solution for adding meta descriptions to pages on a site I have been working on, as this is not available by default. Today it broke through the <a href="http://wordpress.org/extend/plugins/pagemeta/stats/" target="_blank">1,000 downloads</a> mark.</p>
<p>The plugin quite quickly evolved into a solution that allowed for keywords as well as descriptions to be added, as well as the ability to set a custom page title. If required the page title can even be defined in your page template, allowing for dynamic pages /  templates to have specific titles.<span id="more-556"></span></p>
<p>Although unsure if anyone would actually be interested in using it, I decided to publish it to the Plugin Directory anyway. If anything it would allow me to manage the <a href="http://wordpress.org/extend/plugins/pagemeta/changelog/" target="_blank">versions</a> and easily update the handful of blogs that I have installed it on.</p>
<p>I actually thought that my second plugin, <a href="http://wordpress.org/extend/plugins/subheading/" target="_blank">SubHeading</a> would be more popular as there aren&#8217;t many existing solutions in the Directory for this. It&#8217;s not far behind in downloads, with just over <strong>850</strong> to date.</p>
]]></content:encoded>
			<wfw:commentRss>http://36flavours.com/2009/11/wp-page-meta-plugin-1000-downloads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress hosted plugins and Tortoise SVN (Windows)</title>
		<link>http://36flavours.com/2009/10/wordpress-hosted-plugins-and-tortoise-svn-windows/</link>
		<comments>http://36flavours.com/2009/10/wordpress-hosted-plugins-and-tortoise-svn-windows/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 22:47:23 +0000</pubDate>
		<dc:creator>Steve Whiteley</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[tortoise]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://36flavours.com/?p=494</guid>
		<description><![CDATA[Plugins are used to extend the core functionality of WordPress, allowing you to create almost anything you could possibly require. The Plugin Directory contains thousands of community contributed plugins that you can download, rate, and comment on. If you&#8217;re looking to create your own plugin and want to get it noticed, it&#8217;s recommended that you [...]]]></description>
			<content:encoded><![CDATA[<p class="first">Plugins are used to extend the core functionality of <a href="http://wordpress.org/" target="_blank">WordPress</a>, allowing you to create almost anything you could possibly require. The <a href="http://wordpress.org/extend/plugins/" target="_blank">Plugin Directory</a> contains thousands of community contributed plugins that you can download, rate, and comment on.</p>
<p>If you&#8217;re looking to create your own plugin and want to get it noticed, it&#8217;s <em>recommended</em> that you publish and host it in the directory. Here&#8217;s a <strong>quick guide</strong> to take you through the steps of publishing a plugin on a Windows based system.<span id="more-494"></span></p>
<ol>
<li><strong>Download</strong> and install <strong><a href="http://tortoisesvn.net/downloads" target="_blank">Tortoise SVN</a></strong></li>
<li>Request an <strong>SVN repository</strong> using the <a href="http://wordpress.org/extend/plugins/add/" target="_blank">Add Your Plugin</a> page <em>(It may take few hours to get your request approved)</em>.</li>
<li>Once you receive the <strong>SVN credentials</strong> you will be able to access the repository from <em>http://svn.wp-plugins.org/plugin_name</em>.</li>
<li><strong>Checkout</strong> the blank repository from your svn account. (This contains three empty folders &#8211; <em>branches, tag, trunk</em>). To do this, right click the folder you want to Checkout to and select <strong>SVN Checkout</strong>.
<p style="text-align: center; margin-top: 20px;"><img class="aligncenter size-full wp-image-520" title="Initial Checkout" src="http://36flavours.com/wp-content/uploads/2009/10/initial_checkout.png" alt="Initial Checkout" width="401" height="359" /></p>
<p><strong>Enter the URL</strong> of your plugin repository and <strong>click OK</strong>.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-522" title="Initial Checkout URL" src="http://36flavours.com/wp-content/uploads/2009/10/initial_checkout_url.png" alt="Initial Checkout URL" width="468" height="361" /></p>
<p>Once the <strong>process is complete</strong> you will see the three folders that have been added.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-521" title="Initial Checkout Done" src="http://36flavours.com/wp-content/uploads/2009/10/initial_checkout_done.png" alt="Initial Checkout Done" width="559" height="219" /></p>
</li>
<li><strong>Copy</strong> the plugin files into the <strong>trunk</strong> folder and create a <a href="http://wordpress.org/extend/plugins/about/readme.txt" target="_blank">readme.txt</a> file if one is not already present.</li>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-519" title="Copy Files" src="http://36flavours.com/wp-content/uploads/2009/10/copy_files.png" alt="Copy Files" width="459" height="101" /></p>
<li>Commit your changes by right clicking the folder and selecting <strong>SVN commit</strong>.<a href="http://36flavours.com/wp-content/uploads/2009/10/commit.png"></a></li>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-517" title="Commit Plugin" src="http://36flavours.com/wp-content/uploads/2009/10/commit.png" alt="Commit Plugin" width="482" height="393" /></p>
<li>You will be prompted for your <strong>authentication details</strong>, enter your WordPress.org/bbPress.org username and password (the same one you use on the forums). <a href="http://36flavours.com/wp-content/uploads/2009/10/commit_auth.png"></a></li>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-518" title="Commit Auth" src="http://36flavours.com/wp-content/uploads/2009/10/commit_auth.png" alt="Commit Auth" width="346" height="241" /></p>
<li>Now create a <strong>tag</strong>. Right click on the trunk folder and in the context menu go to TortoiseSVN and choose <strong>Branch/Tag</strong>. In the dialogue box change the url path from /trunk to <strong>/tags/0.1</strong> (or whatever you have stated as the stable tag  in the readme file.<a href="http://36flavours.com/wp-content/uploads/2009/10/tag.png"></a></li>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-523" title="Create Tag" src="http://36flavours.com/wp-content/uploads/2009/10/tag.png" alt="Create Tag" width="468" height="393" /></p>
<li>Run <strong>SVN update</strong> on the tags folder <em>(Right click the tags folder and select SVN Update)</em>.</li>
</ol>
<h3>Committing a modified plugin / new version</h3>
<ol>
<li>Make modifications to the <strong>trunk</strong> folder.</li>
<li>Change the <strong>stable tag</strong> value in the readme file to the latest stable version, <em>e.g. 0.1.1</em></li>
<li><strong>SVN commit</strong> the latest changes in the trunk.</li>
<li><strong>Tag</strong> the new version <em>(see step 8 above) </em>.</li>
<li><strong>SVN update</strong> the tags folder.</li>
</ol>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;">download the <a onclick="window.open('http://www.digimantra.com/wp-content/plugins/wordpress-toolbar/toolbar.php?wp-toolbar-tourl=http://tortoisesvn.net/downloads&amp;wp-toolbar-fromurl=http://www.digimantra.com/tutorials/wordpress/publish-wordpress-plugin-on-windows/&amp;wp-toolbar-fromtitle=Publish wordpress plugin on windows using tortoise svn&amp;wp-toolbar-blogurl=http://www.digimantra.com&amp;wp-toolbar-blogtitle=DigiMantra','wordpress-toolbar');return false;" rel="nofollow" href="http://tortoisesvn.net/downloads" target="_blank">Tortoise SVN</a></div>
]]></content:encoded>
			<wfw:commentRss>http://36flavours.com/2009/10/wordpress-hosted-plugins-and-tortoise-svn-windows/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Extending the WordPress mod_rewrite rules</title>
		<link>http://36flavours.com/2009/10/extending-the-wordpress-mod_rewrite-rules/</link>
		<comments>http://36flavours.com/2009/10/extending-the-wordpress-mod_rewrite-rules/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 17:29:23 +0000</pubDate>
		<dc:creator>Steve Whiteley</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[query_vars]]></category>
		<category><![CDATA[rewrite rule]]></category>

		<guid isPermaLink="false">http://36flavours.com/?p=423</guid>
		<description><![CDATA[If you have written a WordPress Plug-in, or a highly customised page, and you want to add a custom rewrite rule then this is article is definitely the one for you. We all know that WordPress is a powerful and pretty impressive blogging platform, and contains many useful features. The problem is finding the features [...]]]></description>
			<content:encoded><![CDATA[<p class="first">If you have written a WordPress Plug-in, or a highly customised page, and you want to add a custom rewrite rule then this is article is definitely the one for you.</p>
<p>We all know that <a href="http://wordpress.org/" target="_blank">WordPress</a> is a powerful and pretty impressive blogging platform, and contains many useful features. The problem is finding the features you need / want. Most of the time they are available &#8211; <em>somewhere</em>.<span id="more-423"></span></p>
<p>In this case, after a numbers of hours research, I&#8217;ve done all the hard work for you when it comes to adding custom rewrite rules. We shall assume we have a page called &#8220;<strong>directory</strong>&#8216;&#8221; with the page ID &#8220;<strong>123</strong>&#8221; and the parent page of name &#8220;<strong>business</strong>&#8220;.</p>
<p>This page <em>(ID: 123)</em> looks for the parameter &#8220;business&#8221; and if is defined, displays the details for the corresponding company. We also want to add the location of the business in the url, but for simplicity we will not pass them through in this example.</p>
<p>The end goal is to have a list of businesses displayed on &#8220;<strong>/business/directory/</strong>&#8221; with links to the business details in the format &#8220;<strong>/business/directory/york-yo31/mybusinessltd/</strong>&#8220;.</p>
<p>To achieve this, we will need to make use of three hooks. The first is the &#8220;<a href="http://codex.wordpress.org/Plugin_API/Action_Reference" target="_blank">init</a>&#8221; hook, which we will use to regenerate the rewrite rules and save them to the database using flush_rules().</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> directory_flush_rewrite<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">flush_rules</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'directory_flush_rewrite'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The second hook is &#8220;<a href="http://codex.wordpress.org/Custom_Queries" target="_blank">query_vars</a>&#8220;. This is required to add the string &#8220;business&#8221; to the list of query variables WordPress understands in order for it to be retrieved on our directory page.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> directory_vars<span style="color: #009900;">&#40;</span><span style="color: #000088;">$public_query_vars</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$public_query_vars</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'business'</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$public_query_vars</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'query_vars'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'directory_vars'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The last hook is called &#8220;<a href="http://codex.wordpress.org/Function_Reference/WP_Rewrite" target="_blank">generate_rewrite_rules</a>&#8221; and allows us to add the custom rewrite rule/s the list of WordPress rewrite rules. Putting the <strong>three code snippets together</strong> will result in the following block of code, which should be added to your &#8220;<strong>functions.php</strong>&#8221; file.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> directory_flush_rewrite<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">flush_rules</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'directory_flush_rewrite'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> directory_vars<span style="color: #009900;">&#40;</span><span style="color: #000088;">$public_query_vars</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$public_query_vars</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'business'</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$public_query_vars</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'query_vars'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'directory_vars'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> directory_rewrite_rules<span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_rewrite</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rules</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'business/directory/(?:\w+)-(?:\w+)/(.*)/?'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'index.php?page_id=123&amp;business='</span><span style="color: #339933;">.</span><span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">preg_index</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rules</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'generate_rewrite_rules'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'directory_rewrite_rules'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The final piece of information you need is how to access the variable passed through form the rewrite rule (&#8220;<strong>business</strong>=mybusinessltd&#8221;). This can be done using using the following:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'business'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// returns 'mybusinessltd' in this example.</span></pre></div></div>

<p>The example Reg Exp used could be modified and improved nad the page name could be matched and used instead of using the page id, but should put you on the right track. As mentioned earlier, you could also pass through the the other parameters (town &amp; postcode) and use them alongside business in your lookup query.</p>
]]></content:encoded>
			<wfw:commentRss>http://36flavours.com/2009/10/extending-the-wordpress-mod_rewrite-rules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using WP-Syntax and the visual editor</title>
		<link>http://36flavours.com/2009/09/using-wp-syntax-and-the-visual-editor/</link>
		<comments>http://36flavours.com/2009/09/using-wp-syntax-and-the-visual-editor/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 20:09:40 +0000</pubDate>
		<dc:creator>Steve Whiteley</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[tinymce]]></category>
		<category><![CDATA[wp-syntax]]></category>

		<guid isPermaLink="false">http://36flavours.com/?p=388</guid>
		<description><![CDATA[Many of the blog posts I write tend to be about web development related topics and will often include a number of code snippets. My current choice of syntax highlighter is WP-Syntax, which supports a wide range of popular languages and has the ability to also include line numbers. The problem with using this plug-in [...]]]></description>
			<content:encoded><![CDATA[<p class="first">Many of the blog posts I write tend to be about web development related topics and will often include a number of code snippets. My current choice of syntax highlighter is <a href="http://wordpress.org/extend/plugins/wp-syntax/" target="_blank">WP-Syntax</a>, which supports a wide range of popular languages and has the ability to also include line numbers.</p>
<p>The problem with using this plug-in is that the <a href="http://wordpress.org/" target="_blank">WordPress</a> WYSIWYG Editor (<a href="http://tinymce.moxiecode.com/" target="_blank">TinyMCE</a>), will <strong>remove any tags and attributes</strong> that it believes to be invalid according to it&#8217;s configuration. As two of the attributes used by this plug-in are custom attributes <em>(escaped/line)</em> they are removed, causing some unexpected output.<span id="more-388"></span></p>
<p>One solution to this problem is to add the custom attributes to the list of valid elements by using the &#8216;<strong>tiny_mce_before_init</strong>&#8216; filter and appending them to the &#8216;<strong>extended_valid_elements&#8217;</strong> string.</p>
<p>The function below can be added to the <em>functions.php</em> file within your theme directory:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> tinymce_wp_syntax<span style="color: #009900;">&#40;</span><span style="color: #000088;">$init</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$values</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'pre[lang|escaped=true|line]'</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$init</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'extended_valid_elements'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$init</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'extended_valid_elements'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$values</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$init</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'extended_valid_elements'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">','</span><span style="color: #339933;">.</span><span style="color: #000088;">$values</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$init</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tiny_mce_before_init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'tinymce_wp_syntax'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Adding this to my blog enables me to continue using the visual editor instead of disabling it and at the same time will allow the other HTML filters to continue as normal <img src='http://36flavours.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p><strong>Note:</strong> You may have to force refresh (ctrl + f5) the post / page editing page for the changes to take effect.</p>
<p><strong>EDIT</strong>: This solution does not fully solve the problem in <a href="http://mu.wordpress.org/">WordPress MU</a> installations, as you need to adjust the allowed post tags used by the content filter.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>CUSTOM_TAGS<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$allowedposttags</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pre'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span>  <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'lang'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'escaped'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'true'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'line'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://36flavours.com/2009/09/using-wp-syntax-and-the-visual-editor/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>WP &#8211; Enable read more links for pages</title>
		<link>http://36flavours.com/2009/08/wp-enable-read-more-links-for-pages/</link>
		<comments>http://36flavours.com/2009/08/wp-enable-read-more-links-for-pages/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 13:11:21 +0000</pubDate>
		<dc:creator>Steve Whiteley</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[2.8.4]]></category>
		<category><![CDATA[pages]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[the_loop]]></category>

		<guid isPermaLink="false">http://36flavours.com/?p=287</guid>
		<description><![CDATA[When listing pages using the_loop(), the latest version of WordPress (2.8.4) does not allow for a &#8220;Read more&#8230;&#8221; link to be appended to a list of pages using the_content() along with the &#60;!&#8211;more&#8211;&#62; quicktag. Although it wasn&#8217;t immediately obvious to me, read more links can be enabled by over-riding the global $more variable and setting [...]]]></description>
			<content:encoded><![CDATA[<p class="first">When listing pages using <em>the_loop()</em>, the latest version of WordPress (<em>2.8.4</em>) does not allow for a &#8220;Read more&#8230;&#8221; link to be appended to a list of pages using <em>the_content()</em> along with the &lt;!&#8211;more&#8211;&gt; quicktag.</p>
<p>Although it wasn&#8217;t immediately obvious to me, read more links can be enabled by over-riding the global <em><strong>$more</strong></em> variable and setting it to <em>false</em>, <strong>before looping</strong> through the result set, for example:<span id="more-287"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$more</span><span style="color: #339933;">;</span> <span style="color: #000088;">$more</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
query_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_type=page'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	the_content<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Read More...'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span></pre></div></div>

<p>I couldn&#8217;t actually discover why this is not the default behaviour when querying pages. There may be a good reason behind it, but in my experience I found it mildly irritating.</p>
]]></content:encoded>
			<wfw:commentRss>http://36flavours.com/2009/08/wp-enable-read-more-links-for-pages/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
