<?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>Matt Varone&#187; WordPress Articles, Tutorials, Plugins, Tips, Resources and News » Matt Varone</title>
	<atom:link href="http://www.mattvarone.com/category/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mattvarone.com</link>
	<description>Creative Developer</description>
	<lastBuildDate>Sun, 07 Mar 2010 12:47:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
<link>http://www.mattvarone.com</link>
<url>http://www.mattvarone.com/wp-content/mbp-favicon/favicon.ico</url>
<title>Matt Varone</title>
</image>
		<item>
		<title>Query Post And Pages With Multiple Meta Values</title>
		<link>http://www.mattvarone.com/wordpress/query-multiple-meta-values/</link>
		<comments>http://www.mattvarone.com/wordpress/query-multiple-meta-values/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 16:37:41 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[RESOURCES]]></category>
		<category><![CDATA[TEMPLATE FUNCTIONS]]></category>

		<guid isPermaLink="false">http://www.mattvarone.com/?p=832</guid>
		<description><![CDATA[— Custom fields give WordPress immense flexibility, by using them correctly you can create very complex applications with the same functionality you could only find in custom CMS. Now for us developers, one of the &#8220;problems&#8221; we might face using multiple custom fields is that there is no easy ( built in ) solution to [...]<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/query-multiple-meta-values/">Query Post And Pages With Multiple Meta Values</a></p>
]]></description>
			<content:encoded><![CDATA[<p>— Custom fields give WordPress immense flexibility, by using them correctly you can create very complex applications with the same functionality you could only find in custom CMS. Now for us developers, one of the &#8220;problems&#8221; we might face using multiple custom fields is that there is no easy ( built in ) solution to query posts or pages based on these multiple values. If you want to do so you have to create a custom ( somewhat complex ) sql query which is clearly not an easy task for most people, and most important it ain&#8217;t a flexible solution you could just include from one project to another.<br />
<span id="more-832"></span><br />
So in the look out for a nice and solid solution I came across this post by  <a rel="friend" href="http://idealienstudios.com/about/">Jamie Oastler</a> a fellow designer who was kind enough to publish this <strong>amazing</strong> function: <a rel="nofollow" href="http://idealienstudios.com/blog/wordpress/custom-field-query-quandry/"><strong>get_post_meta_multiple</strong></a>.<br />
I really encourage you to go ahead and read his post as he makes an excellent and clear explanation of how the function works and how to implement it in your project.</p>
<p>As good as it is, I found that I still needed a bit more flexibility to use it in my projects so I went ahead and made a few small improvements that others might find useful. These give you the option to make your query even more specific, you can:</p>
<ol class="normal">
<li>Select whether you want to retrieve only posts or pages.</li>
<li>Pass a number ( or many numbers ) to select posts only from specific categories.</li>
<li>Limit the number of posts you want to retrieve.</li>
</ol>
<p><br/></p>
<div class="post-box"><small>&rarr; <strong>Get Post Meta Multiple</strong> Modified Function:<a href="http://lab.mattvarone.com/projects/wordpress/getpostmetamultiple.zip"> &darr;  Download</a></small></div>
<h3>Usage Example</h3>
<p>The usage of the function is really simple, as stated before Jamie made an excellent explanation on his blog, so no need to repeat all of that here again.  The three new values I added can be assigned easily when calling the function as you can find in the example bellow:</p>
<pre class="brush: php">

&lt;?php

/*
Function variables:

$aMetaDataList(array) example: array(&#039;meta_key&#039; =&gt; &#039;meta_value&#039;,&#039;meta_key_2&#039; =&gt; &#039;meta_value_2 )
$szType(string) = &quot;post&quot; or &quot;page&quot;
$szCategory(string) = example: &#039;1&#039; or &#039;1,2,3&#039;
$iLimit(integer)
*/

$aMetaDataList = array(
&#039;custom_field_name_1&#039; =&gt; &#039;Yes&#039;,
&#039;custom_field_name_2&#039; =&gt;&#039;No&#039;,
// etc…
);

$szCategory = &#039;3&#039;; // posts only from category 3
$iLimit = 6; // get only 6 posts

$my_posts = get_post_meta_multiple( $aMetaDataList, &#039;post&#039;, $szCategory, $iLimit );

// Once you have the posts just loop trough them as you would do usually

if ($my_posts):
foreach( $my_posts as $post ):

setup_postdata($post);

the_title();

endforeach;
endif;

?&gt;
</pre>
<p>As you can see its very easy to use and it gives us developers huge flexibility to create amazing stuff. Props to Jamie for his great work. Hope you found this useful, if you have any suggestions please feel free to leave it on the comments, thank you!</p>
<h3>The Function</h3>
<pre class="brush: php">

&lt;?php
function get_post_meta_multiple( $aMetaDataList = array(), $szType = &#039;post&#039;, $szCategory = NULL, $iLimit = NULL )
{
global $wpdb;

$szQuerystr = &quot;SELECT p.* FROM $wpdb-&gt;posts AS p&quot;;

if ( $szCategory != NULL AND is_string($szCategory) )
{
$szQuerystr .= &quot; LEFT JOIN $wpdb-&gt;term_relationships ON (p.ID = $wpdb-&gt;term_relationships.object_id) &quot;;
$szQuerystr .= &quot; LEFT JOIN $wpdb-&gt;term_taxonomy ON ($wpdb-&gt;term_relationships.term_taxonomy_id = $wpdb-&gt;term_taxonomy.term_taxonomy_id) &quot;;
}

$szQuerystr .=  &quot;WHERE p.ID IN ( &quot;;

$szQuerystr .= &quot;SELECT post_id FROM $wpdb-&gt;postmeta WHERE &quot;;

$aInnerqry = array();

foreach($aMetaDataList as $szKey =&gt; $szValue)
{
$aInnerqry[] = $wpdb-&gt;prepare( &quot;(meta_key = %s AND meta_value = %s)&quot;, $szKey, $szValue );
}

$szQuerystr .= implode(&quot; OR &quot;, $aInnerqry);

$szQuerystr .= &quot; GROUP BY post_id &quot;;
$szQuerystr .= &quot;HAVING count(*) = &quot; . count($aMetaDataList);

$szQuerystr .= &quot;) AND p.post_status = &#039;publish&#039; AND p.post_type = &#039;&quot;.$szType.&quot;&#039;&quot;;

if ( $szCategory != NULL AND is_string($szCategory) )
$szQuerystr .= &quot; AND $wpdb-&gt;term_taxonomy.term_id IN(&quot;.$szCategory.&quot;)&quot;;

$szQuerystr .= &quot; ORDER BY p.post_title ASC&quot;;

if ( $iLimit != NULL AND is_int($iLimit) )
$szQuerystr .= &quot; LIMIT &quot;.$iLimit;

$aMetaResults = $wpdb-&gt;get_results($szQuerystr, OBJECT);

return $aMetaResults;
}
?&gt;
</pre>
<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/query-multiple-meta-values/">Query Post And Pages With Multiple Meta Values</a></p>

	<h4 class="related">Somewhat related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.mattvarone.com/wordpress/output-clean-valid-xhtml/" title="WordPress: Output Clean and Valid HTML Content (October 30, 2009)">WordPress: Output Clean and Valid HTML Content</a> (10)</li>
	<li><a href="http://www.mattvarone.com/wordpress/list-recent-posts-in-wordpress/" title="List recent posts in WordPress (September 15, 2008)">List recent posts in WordPress</a> (4)</li>
	<li><a href="http://www.mattvarone.com/wordpress/list-users/" title="Custom Query: List WordPress Users (November 19, 2008)">Custom Query: List WordPress Users</a> (68)</li>
	<li><a href="http://www.mattvarone.com/wordpress/useful-functions-for-wordpress/" title="Useful custom functions for WordPress (November 11, 2008)">Useful custom functions for WordPress</a> (64)</li>
	<li><a href="http://www.mattvarone.com/wordpress/functionsphp-wordpress-themes/" title="Taking Advantage of Functions.php in WordPress Themes (October 23, 2008)">Taking Advantage of Functions.php in WordPress Themes</a> (43)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.mattvarone.com/wordpress/query-multiple-meta-values/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Dynamic To Top WordPress Plugin</title>
		<link>http://www.mattvarone.com/wordpress/dynamic-to-top-wordpress-plugin/</link>
		<comments>http://www.mattvarone.com/wordpress/dynamic-to-top-wordpress-plugin/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 00:36:43 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[INTERFACE DESIGN]]></category>
		<category><![CDATA[LAYOUT]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PLUGINS]]></category>

		<guid isPermaLink="false">http://www.mattvarone.com/?p=778</guid>
		<description><![CDATA[&#8212; After some requests I decided to update* and wrap UItoTop into a plugin for WordPress.  This plugin  automatically adds a dynamic &#8220;To Top&#8221; button to easily scroll long pages back to the top. This way  is much more simple to add the functionality to a theme as it only involves uploading [...]<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/dynamic-to-top-wordpress-plugin/">Dynamic To Top WordPress Plugin</a></p>
]]></description>
			<content:encoded><![CDATA[<p>&mdash; After some requests I decided to update* and wrap <a href="http://www.mattvarone.com/web-design/uitotop-jquery-plugin/" title="jQuery Dynamic Scroll to Top">UItoTop</a> into a plugin for WordPress.  This plugin <strong> automatically adds a dynamic &#8220;To Top&#8221; button to easily scroll long pages back to the top</strong>. This way  is much more simple to add the functionality to a theme as it only involves uploading and activating the plugin.</p>
<div class="post-box"><small>→ Dynamic To Top: <a href="http://wordpress.org/extend/plugins/dynamic-to-top/">Plugin on WordPress Website</a> | <a href="http://downloads.wordpress.org/plugin/dynamic-to-top.zip">↓ Download</a></small></div>
<h3>Installation</h3>
<ol class="normal">
<li><strong>Download &#8220;Dynamic To Top&#8221;</strong> from the link above and <strong>unzip the files</strong> somewhere on your computer.</li>
<li><strong>Upload &#8220;dynamic-to-top&#8221; folder</strong> into your plugins directory.</li>
<li><strong>Activate</strong> the plugin.</li>
<li>Have fun!</li>
</ol>
<p><em>* Big thanks to Rémy Tourbiez for his contribution to the code.</em></p>
<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/dynamic-to-top-wordpress-plugin/">Dynamic To Top WordPress Plugin</a></p>

	<h4 class="related">Somewhat related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.mattvarone.com/web-design/uitotop-jquery-plugin/" title="UItoTop jQuery Plugin (September 3, 2009)">UItoTop jQuery Plugin</a> (6)</li>
	<li><a href="http://www.mattvarone.com/wordpress/scrnshotsrss-plugin-update-2/" title="ScrnshotsRSS plugin 2.0 update (November 10, 2008)">ScrnshotsRSS plugin 2.0 update</a> (2)</li>
	<li><a href="http://www.mattvarone.com/web-design/daily-calendar-dates-with-css/" title="Daily Calendar Dates With CSS (September 23, 2008)">Daily Calendar Dates With CSS</a> (6)</li>
	<li><a href="http://www.mattvarone.com/wordpress/output-clean-valid-xhtml/" title="WordPress: Output Clean and Valid HTML Content (October 30, 2009)">WordPress: Output Clean and Valid HTML Content</a> (10)</li>
	<li><a href="http://www.mattvarone.com/web-design/website-revamped/" title="Website revamped! (June 22, 2008)">Website revamped!</a> (1)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.mattvarone.com/wordpress/dynamic-to-top-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>WordPress: Output Clean and Valid HTML Content</title>
		<link>http://www.mattvarone.com/wordpress/output-clean-valid-xhtml/</link>
		<comments>http://www.mattvarone.com/wordpress/output-clean-valid-xhtml/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 12:39:47 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[ACCESSIBILTY]]></category>
		<category><![CDATA[HTML and XHTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[RESOURCES]]></category>
		<category><![CDATA[TEMPLATE FUNCTIONS]]></category>

		<guid isPermaLink="false">http://www.mattvarone.com/?p=770</guid>
		<description><![CDATA[&#8212; I found that more than often clients generate a lot of garbage html in the post content with things like divs, p , a, etc. tags which haven&#8217;t been closed or opened properly. This makes the website fail to validate against W3C standards which in between other things, could potentially affect the site&#8217;s ranking [...]<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/output-clean-valid-xhtml/">WordPress: Output Clean and Valid HTML Content</a></p>
]]></description>
			<content:encoded><![CDATA[<p>&mdash; I found that more than often clients generate a lot of garbage html in the post content with things like <em>divs</em>, <em>p</em> , <em>a</em>, etc. tags which haven&#8217;t been closed or opened properly. This makes the website fail to validate against W3C standards which in between other things, could potentially affect the site&#8217;s ranking and its accessibility. Of course asking clients to switch to the HTML view to clean the content is out of the question, so a solution is needed, and been that this could happen to any site makes it something that we should take in count upfront when building a professional website.  </p>
<div class="post-box"><small>→ Clean The Content Function: <a href="http://lab.mattvarone.com/demos/clean/mattvarone-cleanwpcontent.zip">↓ Download</a> </small></div>
<p><span id="more-770"></span></p>
<p>After some research on the subject I found <strong><a href="http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/index.php">htmLawed</a></strong>, a PHP code to purify and filter HTML that works incredibly well. Props to the htmLawed team for their awesome work!. To merge it with WordPress I wrote a little function which automatically filters the content coming from the post. The results are amazing, htmLawed cleans and filters all the bad content and makes the pages validate again right away!</p>
<pre class="brush: php">
	include_once ( TEMPLATEPATH . &#039;/htmLawed.php&#039; ); // THIS FILE SHOULD RESIDE IN THE THEME FOLDER.

	function clean_the_content( $content )
	{
		$szPostContent = $content;
		$szRemoveFilter = array( &quot;~&lt;p[^&gt;]*&gt;\s?&lt;/p&gt;~&quot;, &quot;~&lt;a[^&gt;]*&gt;\s?&lt;/a&gt;~&quot;, &quot;~&lt;font[^&gt;]*&gt;~&quot;, &quot;~&lt;\/font&gt;~&quot;, &quot;~&lt;span[^&gt;]*&gt;\s?&lt;/span&gt;~&quot; );
		$szPostContent = preg_replace( $szRemoveFilter, &#039;&#039; , $szPostContent);
		$szPostContent = htmLawed($szPostContent);
		return $szPostContent;
	}

	add_filter(&#039;the_content&#039;, &#039;clean_the_content&#039;);
</pre>
<p>To use this function simple drop the two files in your theme directory and you are set to go!. Hope you find this post useful. Cheers!</p>
<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/output-clean-valid-xhtml/">WordPress: Output Clean and Valid HTML Content</a></p>

	<h4 class="related">Somewhat related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.mattvarone.com/wordpress/query-multiple-meta-values/" title="Query Post And Pages With Multiple Meta Values (March 5, 2010)">Query Post And Pages With Multiple Meta Values</a> (3)</li>
	<li><a href="http://www.mattvarone.com/wordpress/list-recent-posts-in-wordpress/" title="List recent posts in WordPress (September 15, 2008)">List recent posts in WordPress</a> (4)</li>
	<li><a href="http://www.mattvarone.com/wordpress/list-users/" title="Custom Query: List WordPress Users (November 19, 2008)">Custom Query: List WordPress Users</a> (68)</li>
	<li><a href="http://www.mattvarone.com/wordpress/useful-functions-for-wordpress/" title="Useful custom functions for WordPress (November 11, 2008)">Useful custom functions for WordPress</a> (64)</li>
	<li><a href="http://www.mattvarone.com/wordpress/functionsphp-wordpress-themes/" title="Taking Advantage of Functions.php in WordPress Themes (October 23, 2008)">Taking Advantage of Functions.php in WordPress Themes</a> (43)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.mattvarone.com/wordpress/output-clean-valid-xhtml/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Custom WordPress function to check page parent</title>
		<link>http://www.mattvarone.com/wordpress/wordpress-check-page-parent/</link>
		<comments>http://www.mattvarone.com/wordpress/wordpress-check-page-parent/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 21:39:14 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[TEMPLATE FUNCTIONS]]></category>

		<guid isPermaLink="false">http://www.mattvarone.com/?p=694</guid>
		<description><![CDATA[&#8212; Quick update to the is_subpage() function. Basically it&#8217;s does the same but now it also accepts an integer to check if the current page is a child of certain ID. This way its easier to track if  the current location is a subpage of a certain page. If it matches it will return [...]<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/wordpress-check-page-parent/">Custom WordPress function to check page parent</a></p>
]]></description>
			<content:encoded><![CDATA[<p>&mdash; Quick update to the <a href="http://www.mattvarone.com/wordpress/is_subpage-function/">is_subpage() function</a>. Basically it&#8217;s does the same but now it also accepts an integer to check if the current page is a child of certain ID. This way its easier to track if  the current location is a subpage of a certain page. If it matches it will return a <strong>true</strong> value otherwise, it will be <strong>false</strong>.</p>
<div class="post-box"><small>→  Download <a href="http://lab.mattvarone.com/demos/wp-functions/functions-part4.zip">the function here</a></small></div>
<pre class="brush: php">
function is_subpage( $iID = null )
	{
		global $post, $wpdb;

		if ( is_page() AND isset( $post-&gt;post_parent ) != 0 )
		{
			$aParent = $wpdb-&gt;get_row( $wpdb-&gt;prepare( &quot;SELECT ID FROM $wpdb-&gt;posts WHERE ID = %d AND post_type = &#039;page&#039; LIMIT 1&quot;, $post-&gt;post_parent ) );

			if ( is_int( $iID ) &gt; 0 )
				if ( $aParent-&gt;ID == $iID ) return true; else return false;
			else
				if ( $aParent-&gt;ID )	return true; else return false;

		}
		else
		{
			return false;
		}
	}

/* EXAMPLE */

if ( is_page(&#039;producs&#039;) OR is_subpage( 8 ) )
{
  //do something
};
</pre>
<p>Cheers!</p>
<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/wordpress-check-page-parent/">Custom WordPress function to check page parent</a></p>

	<h4 class="related">Somewhat related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.mattvarone.com/wordpress/output-clean-valid-xhtml/" title="WordPress: Output Clean and Valid HTML Content (October 30, 2009)">WordPress: Output Clean and Valid HTML Content</a> (10)</li>
	<li><a href="http://www.mattvarone.com/wordpress/query-multiple-meta-values/" title="Query Post And Pages With Multiple Meta Values (March 5, 2010)">Query Post And Pages With Multiple Meta Values</a> (3)</li>
	<li><a href="http://www.mattvarone.com/wordpress/list-recent-posts-in-wordpress/" title="List recent posts in WordPress (September 15, 2008)">List recent posts in WordPress</a> (4)</li>
	<li><a href="http://www.mattvarone.com/wordpress/list-users/" title="Custom Query: List WordPress Users (November 19, 2008)">Custom Query: List WordPress Users</a> (68)</li>
	<li><a href="http://www.mattvarone.com/wordpress/add-css-javascript-wordpress-theme/" title="Correct way of adding CSS and Javascript references to WordPress themes (October 5, 2008)">Correct way of adding CSS and Javascript references to WordPress themes</a> (11)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.mattvarone.com/wordpress/wordpress-check-page-parent/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>is_subpage() &#8211; Custom Conditional Function</title>
		<link>http://www.mattvarone.com/wordpress/is_subpage-function/</link>
		<comments>http://www.mattvarone.com/wordpress/is_subpage-function/#comments</comments>
		<pubDate>Sat, 29 Nov 2008 17:06:24 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[RESOURCES]]></category>
		<category><![CDATA[TEMPLATES]]></category>

		<guid isPermaLink="false">http://www.mattvarone.com/?p=621</guid>
		<description><![CDATA[This function has been updated and improved. Click here to go to the newer version.
&#8212;  Quick conditional function for WordPress to check if the current page is a sub page. It works both inside and outside the main loop, only for 2.5 and upwards.
→  Download the function here
Example
Same way as you use is_page, [...]<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/is_subpage-function/">is_subpage() &#8211; Custom Conditional Function</a></p>
]]></description>
			<content:encoded><![CDATA[<p class="message-box alert">This function has been updated and improved. <a href="http://www.mattvarone.com/wordpress/wordpress-check-page-parent/">Click here to go to the newer version</a>.</p>
<p>&mdash;  Quick conditional <a href="http://www.mattvarone.com/wordpress/functionsphp-wordpress-themes/">function for WordPress</a> to check if the current page is a sub page. It works both inside and outside the main loop, only for 2.5 and upwards.</p>
<div class="post-box"><small>→  Download <a href="http://lab.mattvarone.com/demos/wp-functions/functions-part3.zip">the function here</a></small></div>
<h3>Example</h3>
<p>Same way as you use is_page, is_home, etc.</p>
<pre class="brush: php">
&lt;?php if (have_posts()) : ?&gt;

	&lt;?php while (have_posts()) : the_post(); ?&gt;

		&lt;?php if ( is_subpage() ): ?&gt;
			&lt;p&gt; This is a subpage &lt;/p&gt;
		&lt;?php endif ?&gt;

	&lt;?php endwhile; ?&gt;
</pre>
<p><span id="more-621"></span></p>
<h3>The Function</h3>
<pre class="brush: php">

function is_subpage()
{
	global $post, $wpdb;

	if ( is_page() AND isset( $post-&gt;post_parent ) != 0 )
	{
		$aParent = $wpdb-&gt;get_row( $wpdb-&gt;prepare( &quot;SELECT ID FROM $wpdb-&gt;posts WHERE ID = %d AND post_type = &#039;page&#039; LIMIT 1&quot;, $post-&gt;post_parent ) );
		if ( $aParent-&gt;ID ) return true; else return false;
	}
	else
	{
		return false;
	}
}
</pre>
<p>Im not sure why WordPress didn&#8217;t include a function like this by default, i hope you find it useful.<br />
Cheers!</p>
<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/is_subpage-function/">is_subpage() &#8211; Custom Conditional Function</a></p>

	<h4 class="related">Somewhat related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.mattvarone.com/wordpress/output-clean-valid-xhtml/" title="WordPress: Output Clean and Valid HTML Content (October 30, 2009)">WordPress: Output Clean and Valid HTML Content</a> (10)</li>
	<li><a href="http://www.mattvarone.com/wordpress/scrnshotsrss-plugin-update-2/" title="ScrnshotsRSS plugin 2.0 update (November 10, 2008)">ScrnshotsRSS plugin 2.0 update</a> (2)</li>
	<li><a href="http://www.mattvarone.com/wordpress/query-multiple-meta-values/" title="Query Post And Pages With Multiple Meta Values (March 5, 2010)">Query Post And Pages With Multiple Meta Values</a> (3)</li>
	<li><a href="http://www.mattvarone.com/web-design/php-contact-form-script/" title="PHP Contact form script (September 16, 2008)">PHP Contact form script</a> (5)</li>
	<li><a href="http://www.mattvarone.com/wordpress/list-recent-posts-in-wordpress/" title="List recent posts in WordPress (September 15, 2008)">List recent posts in WordPress</a> (4)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.mattvarone.com/wordpress/is_subpage-function/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>WordPress SEO: Control Search Engines</title>
		<link>http://www.mattvarone.com/wordpress/seo-index-search-engines/</link>
		<comments>http://www.mattvarone.com/wordpress/seo-index-search-engines/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 00:10:31 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[RESOURCES]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[TIP]]></category>

		<guid isPermaLink="false">http://www.mattvarone.com/?p=571</guid>
		<description><![CDATA[— When you build up a website you should keep in mind how you´ll want search engines to index your content. The main reason you&#8217;ll want to take control is to get all the juice out of your content and prevent possible indexing problems. Although this apply for all sites in this article I&#8217;m going [...]<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/seo-index-search-engines/">WordPress SEO: Control Search Engines</a></p>
]]></description>
			<content:encoded><![CDATA[<p>— When you build up a website you should keep in mind how you´ll want search engines to index your content. The main reason you&#8217;ll want to take control is to get all the juice out of your content and prevent possible indexing problems. Although this apply for all sites in this article I&#8217;m going to focus in a WordPress based site situation.</p>
<h3>Why you should control search engines</h3>
<p>It&#8217;s very important to know what and how you want search engines to index your site, if you don&#8217;t take the time to do it you are relying on <em>them</em> to &#8220;figure it out&#8221; for you, and that is not good. In a default WordPress installation you get different instances of your content repeated trough the site. For example take a post. It will appear in the homepage, in it&#8217;s single version, listed under a category, in the author pages, in search result, etc. Are you comfortable having duplicated content indexed and letting Search Engines pick/guess which version of it is the one you consider the most relevant? I bet you wont. Thats why it&#8217;s good to take this into consideration.<br />
<span id="more-571"></span></p>
<h3>What to index</h3>
<p>There&#8217;s a lot of dicussion around the web of what you should and shouldn&#8217;t index. Unfortunately for us there isn&#8217;t one solution that will fit perfectly for all sites, to achieve the best results it will usually require planning ahead and even doing some experimenting and tweaking on the road. The type of content, the blog structure even the theme structure and its elements are things that affects these plans and should be taken into consideration prior making a decision. For example, not all themes will always show duplicate content. If your theme category pages show excerpts of the content that you previously took the time to write, then it certainly is good to index that page. Same thing could happen with tags, author and archives pages as well. If those provide different or extra content then why would you not index them.</p>
<h3>How can you control this?</h3>
<h4>Create a robots.txt file</h4>
<p>Im sure most of you know what a <a href="http://en.wikipedia.org/wiki/Robots.txt">robots.txt</a> file is for. For those who don&#8217;t know, it&#8217;s basically a file that goes in the root folder of your site with instructions of what specific files or directories you want to allow or disallow Search Engines to index. Here is a sample of a WordPress robots.txt file:</p>
<pre class="brush: html">
User-agent: *
Disallow: /tag
Disallow: /author
</pre>
<p>To prevent duplicated content, in the sample above I decided to disallow the indexing of everything under /tag and /author. Remember not all themes/sites should have these same instructions, you have to choose carefully what you&#8217;ll want to remove. As a live example you can see <a href="http://www.mattvarone.com/robots.txt" rel="nofollow">my robots.txt</a> file. If you feel uncomfortable editing files in your server there&#8217;s a nice <a href="http://wordpress.org/extend/plugins/kb-robotstxt">plugin</a> to create this file from within the Admin panel.</p>
<h4>Add the correct robots meta tags to your theme pages</h4>
<p>If you feel you want to have a more specific control, or if you don&#8217;t trust enough your robots.txt file, you can always opt to use the <a href="http://www.robotstxt.org/meta.html">robots meta tag</a>. You can use this tag to tell Search Engines not to index the content of a page, and/or not scan it for links to follow. Joost de Valk has put together a great <a href="http://yoast.com/wordpress/meta-robots-wordpress-plugin/">plugin</a> to handle this easily from within WordPress control panel.</p>
<h3>Conclusion</h3>
<p>Your site might had been loosing relevance in search results because of this so I encourage you to think about it and give it the time it deserves. If you have any tip or suggestion feel free to add it in the comments.</p>
<p>Hope you enjoyed,<br />
Thanks!</p>
<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/seo-index-search-engines/">WordPress SEO: Control Search Engines</a></p>

	<h4 class="related">Somewhat related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.mattvarone.com/wordpress/list-users/" title="Custom Query: List WordPress Users (November 19, 2008)">Custom Query: List WordPress Users</a> (68)</li>
	<li><a href="http://www.mattvarone.com/wordpress/output-clean-valid-xhtml/" title="WordPress: Output Clean and Valid HTML Content (October 30, 2009)">WordPress: Output Clean and Valid HTML Content</a> (10)</li>
	<li><a href="http://www.mattvarone.com/wordpress/wordpress-textmate-bundle/" title="WordPress Textmate bundle (September 15, 2008)">WordPress Textmate bundle</a> (3)</li>
	<li><a href="http://www.mattvarone.com/web-design/using-stacks-for-screenshots/" title="Using Stacks for Screenshots (September 19, 2008)">Using Stacks for Screenshots</a> (0)</li>
	<li><a href="http://www.mattvarone.com/wordpress/useful-functions-for-wordpress/" title="Useful custom functions for WordPress (November 11, 2008)">Useful custom functions for WordPress</a> (64)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.mattvarone.com/wordpress/seo-index-search-engines/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
