<?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>Devdevote&#187; Wordpress hacks</title>
	<atom:link href="http://www.devdevote.com/cms/wordpress-hacks/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devdevote.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 06 Mar 2011 13:06:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>delete_post_link()</title>
		<link>http://www.devdevote.com/cms/wordpress-hacks/delete_post_link</link>
		<comments>http://www.devdevote.com/cms/wordpress-hacks/delete_post_link#comments</comments>
		<pubDate>Sat, 16 Jan 2010 14:55:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Wordpress hacks]]></category>

		<guid isPermaLink="false">http://www.devdevote.com/?p=47</guid>
		<description><![CDATA[I have created a function called "Delete Post Link". If you are logged in you will see a link which allows you to delete the current page or post, even without visiting admin.]]></description>
			<content:encoded><![CDATA[<p>In most WordPress themes, if you are logged in, there is an &#8221;Edit Post&#8221; link. That way you can go directly into edit the current post.</p>
<p>I have created a function called &#8221;Delete Post Link&#8221;. If you are logged in you will see a link which allows you to delete the current page or post, even without visiting admin.</p>
<h3 class="red">Warning! You should be very careful using this function!</h3>
<pre>function wp_delete_post_link($link = 'Delete This', $before = '', $after = '')
{
	global $post;
	if ( $post-&gt;post_type == 'page' ) {
		if ( !current_user_can( 'edit_page', $post-&gt;ID ) )
			return;
	} else {
		if ( !current_user_can( 'edit_post', $post-&gt;ID ) )
			return;
	}
	$link = "&lt;a href='" . wp_nonce_url( get_bloginfo('url') . "/wp-admin/post.php?action=delete&amp;amp;post=" . $post-&gt;ID, 'delete-post_' . $post-&gt;ID) . "'&gt;".$link."&lt;/a&gt;";
	echo $before . $link . $after;
}</pre>
<p>I recommend you to put the function into your functions.php file in your theme folder. When done just put the function into your theme like this:</p>
<pre>wp_delete_post_link('Delete this post / page', '&lt;p&gt;', '&lt;/p&gt;')</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.devdevote.com/cms/wordpress-hacks/delete_post_link/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>get_content() WITH formatting</title>
		<link>http://www.devdevote.com/cms/wordpress-hacks/get_content-with-formatting</link>
		<comments>http://www.devdevote.com/cms/wordpress-hacks/get_content-with-formatting#comments</comments>
		<pubDate>Sat, 16 Jan 2010 14:55:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Wordpress hacks]]></category>

		<guid isPermaLink="false">http://www.devdevote.com/?p=45</guid>
		<description><![CDATA[Normally the get_the_content() tag returns the content WITHOUT formatting. I found out a solution in Wordpress core to make get_the_content()  tag return the same content as the_content().]]></description>
			<content:encoded><![CDATA[<h3 class="red">The problem</h3>
<p>Normally the <em>get_the_content()</em> tag returns the content WITHOUT formatting. Only <em>the_content()</em> will print the content WITH formatting.</p>
<pre>&lt;?php echo get_the_content(); ?&gt;
&lt;?php the_content(); ?&gt;</pre>
<h3 class="green">The solution</h3>
<p>I found out a solution in WordPress core to make <em>get_the_content()</em> tag return the same content as <em>the_content()</em>. Put this code into your functions.php in your theme folder.</p>
<pre>function get_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '')
{
	$content = get_the_content($more_link_text, $stripteaser, $more_file);
	$content = apply_filters('the_content', $content);
	$content = str_replace(']]&gt;', ']]&amp;gt;', $content);
	return $content;
}</pre>
<h3>The function call</h3>
<p>Call the function inside the loop somewhere in your theme.</p>
<pre>&lt;?php echo get_content(); ?&gt;</pre>
<h2>Improvements</h2>
<p>Do you have any ideas, bugs, features or anything else to improve the code? Write a comment and I’ll look into it</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devdevote.com/cms/wordpress-hacks/get_content-with-formatting/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>get_depth()</title>
		<link>http://www.devdevote.com/cms/wordpress-hacks/get_depth</link>
		<comments>http://www.devdevote.com/cms/wordpress-hacks/get_depth#comments</comments>
		<pubDate>Sat, 16 Jan 2010 14:54:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Wordpress hacks]]></category>

		<guid isPermaLink="false">http://www.devdevote.com/?p=43</guid>
		<description><![CDATA[I created a function that returns the depth of a page or category. The depth is how many levels from the root the page or category in its hierarchy. The root level number is 0.]]></description>
			<content:encoded><![CDATA[<h3 class="red">The problem</h3>
<p>As far as I know there is no function in WordPress that return the page or category depth.</p>
<h3 class="green">The solution</h3>
<p>I created a function that returns the depth of a page or category. The depth is how many levels from the root the page or category in its hierarchy. The root level number is 0.</p>
<pre>function get_depth($id = '', $depth = '', $i = 0)
{
	global $wpdb;

	if($depth == '')
	{
		if(is_page())
		{
			if($id == '')
			{
				global $post;
				$id = $post-&gt;ID;
			}
			$depth = $wpdb-&gt;get_var("SELECT post_parent FROM $wpdb-&gt;posts WHERE ID = '".$id."'");
			return get_depth($id, $depth, $i);
		}
		elseif(is_category())
		{

			if($id == '')
			{
				global $cat;
				$id = $cat;
			}
			$depth = $wpdb-&gt;get_var("SELECT parent FROM $wpdb-&gt;term_taxonomy WHERE term_id = '".$id."'");
			return get_depth($id, $depth, $i);
		}
		elseif(is_single())
		{
			if($id == '')
			{
				$category = get_the_category();
				$id = $category[0]-&gt;cat_ID;
			}
			$depth = $wpdb-&gt;get_var("SELECT parent FROM $wpdb-&gt;term_taxonomy WHERE term_id = '".$id."'");
			return get_depth($id, $depth, $i);
		}
	}
	elseif($depth == '0')
	{
		return $i;
	}
	elseif(is_single() || is_category())
	{
		$depth = $wpdb-&gt;get_var("SELECT parent FROM $wpdb-&gt;term_taxonomy WHERE term_id = '".$depth."'");
		$i++;
		return get_depth($id, $depth, $i);
	}
	elseif(is_page())
	{
		$depth = $wpdb-&gt;get_var("SELECT post_parent FROM $wpdb-&gt;posts WHERE ID = '".$depth."'");
		$i++;
		return get_depth($id, $depth, $i);
	}
}</pre>
<h3>Function call</h3>
<p>Send an ID with the function or it will use current ID to get the depth. Call the function  somewhere in your theme.</p>
<ul>
<li><strong>In a category</strong> &#8211; It will return the depth of the current category, if no ID is sent.</li>
<li><strong>In a page</strong> &#8211; It will return the depth of the current page, if no ID is sent.</li>
<li><strong>In a post</strong> &#8211; It will return the depth of the first category assigned to the post, if no ID is sent.</li>
</ul>
<pre>&lt;?php echo get_depth(); ?&gt;
&lt;?php echo get_depth(2); ?&gt;</pre>
<h2>Alternative (for page depth only)</h2>
<p>Here comes a much shorter alternative if you only need to get the depth of pages. This works on page.php. If you are using it in other places, make sure the $post variable are correct.</p>
<pre>&lt;?php echo count($post-&gt;ancestors); ?&gt;</pre>
<h2>Alternative (for category depth only)</h2>
<p>This code works with archive.php or category.php. If you are using another template file, you need to insert the category ID into the $cat variable.</p>
<pre>&lt;?php
$cats_str = get_category_parents($cat, false, '%#%');
$cats_array = explode('%#%', $cats_str);
$cat_depth = sizeof($cats_array)-2;
echo $cat_depth;
?&gt;</pre>
<h2>Contributors</h2>
<ul>
<li><a title="vybes" href="http://webfundi.wordpress.com/">vybes</a></li>
<li><a title="Nathan Rice" href="http://www.nathanrice.net/">Nathan Rice</a></li>
</ul>
<h2>Improvements</h2>
<p>Do you have any ideas, bugs, features or anything else to improve the code? Write a comment and I’ll look into it.</p>
<h2>Other solutions</h2>
<ul>
<li><a title="Nicholas Roussos - is_child function" href="http://www.nicholasroussos.com/general/wordpress-is_child-function/">Nicholas Roussos &#8211; is_child function</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.devdevote.com/cms/wordpress-hacks/get_depth/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>get_id_by_post_name()</title>
		<link>http://www.devdevote.com/cms/wordpress-hacks/get_id_by_post_name</link>
		<comments>http://www.devdevote.com/cms/wordpress-hacks/get_id_by_post_name#comments</comments>
		<pubDate>Sat, 16 Jan 2010 14:53:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Wordpress hacks]]></category>

		<guid isPermaLink="false">http://www.devdevote.com/?p=41</guid>
		<description><![CDATA[The function converts a post / page name to a post /page ID.]]></description>
			<content:encoded><![CDATA[<h3 class="red">The problem</h3>
<p>As far as I know there are no function in WordPress that &#8221;converts&#8221; a page /post name to an ID.</p>
<h3 class="green">The solution</h3>
<p>The function converts a post / page name to a post /page ID.</p>
<pre>function get_id_by_post_name($post_name)
{
	global $wpdb;
	$id = $wpdb-&gt;get_var("SELECT ID FROM $wpdb-&gt;posts WHERE post_name = '".$post_name."'");
	return $id;
}</pre>
<h3>Function call</h3>
<p>Call the function somewhere in your theme.</p>
<pre>&lt;?php echo get_id_by_post_name('my-post-name'); ?&gt;</pre>
<h2>Improvements</h2>
<p>Do you have any ideas, bugs, features or anything else to improve the code? Write a comment and I’ll look into it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devdevote.com/cms/wordpress-hacks/get_id_by_post_name/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>get_permalink_by_name()</title>
		<link>http://www.devdevote.com/cms/wordpress-hacks/get_permalink_by_name</link>
		<comments>http://www.devdevote.com/cms/wordpress-hacks/get_permalink_by_name#comments</comments>
		<pubDate>Sat, 16 Jan 2010 14:53:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Wordpress hacks]]></category>

		<guid isPermaLink="false">http://www.devdevote.com/?p=39</guid>
		<description><![CDATA[I created a function that returns an URL when sending a post / page name as an in parameter. Put the function into your functions.php in your theme folder.]]></description>
			<content:encoded><![CDATA[<h3 class="red">The problem</h3>
<p>WordPress have a built in function called get_permalink. However, it only accepts an ID as an in parameter. I can&#8217;t get a permalink if I have a page / post name.</p>
<h3 class="green">The solution</h3>
<p>I created a function that returns an URL when sending a post / page name as an in parameter. Put the function into your functions.php in your theme folder.</p>
<pre>function get_permalink_by_name($post_name)
{
     global $post;
     global $wpdb;
     $id = $wpdb-&gt;get_var("SELECT ID FROM $wpdb-&gt;posts WHERE post_name = '".$post_name."'");
     return get_permalink($id);
}</pre>
<h3>The function call</h3>
<p>Call the function inside the loop, somewhere in your theme. The code below prints out the current user information.</p>
<pre>echo get_permalink_by_name('my-post-name');</pre>
<h2>Improvements</h2>
<p>Do you have any ideas, bugs, features or anything else to improve the code? Write a comment and I’ll look into it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devdevote.com/cms/wordpress-hacks/get_permalink_by_name/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>get_single_cat()</title>
		<link>http://www.devdevote.com/cms/wordpress-hacks/get_single_cat</link>
		<comments>http://www.devdevote.com/cms/wordpress-hacks/get_single_cat#comments</comments>
		<pubDate>Sat, 16 Jan 2010 14:52:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Wordpress hacks]]></category>

		<guid isPermaLink="false">http://www.devdevote.com/?p=37</guid>
		<description><![CDATA[I created a function that returns a value depending of the input type. Put the function into your functions.php in your theme folder.]]></description>
			<content:encoded><![CDATA[<h3 class="red">The problem</h3>
<p>WordPress have a built in function called <a title="get_the_category" href="http://codex.wordpress.org/Function_Reference/get_the_category">get_the_category()</a>. Because the possibility to have posts in more than one category, it returns an array.</p>
<pre>$category = get_the_category();
echo $category[0]-&gt;cat_name;</pre>
<p>The result of the function is inserted into an array. It then echos the first category title. The code is not as short and easy as it could be.</p>
<h3 class="green">The solution</h3>
<p>I created a function that returns a value depending of the input type. Put the function into your functions.php in your theme folder.</p>
<pre>function get_single_cat($type = 'ID')
{
     $category = get_the_category();

     switch ($type)
     {
          case 'ID':
               return $category[0]-&gt;cat_ID;
               break;
          case 'title':
               return $category[0]-&gt;cat_name;
               break;
          case 'name':
               return $category[0]-&gt;category_nicename;
               break;
          case 'description':
               return $category[0]-&gt;category_description;
               break;
          case 'parent':
               return $category[0]-&gt;category_parent;
               break;
          case 'count':
               return $category[0]-&gt;category_count;
               break;
          default:
               return;
     }
}</pre>
<h3>The function call</h3>
<p>Call the function inside the post loop somewhere in your theme. The example below prints out all the current category information.</p>
<pre>echo get_single_cat();
echo get_single_cat('ID');
echo get_single_cat('title');
echo get_single_cat('name');
echo get_single_cat('description');
echo get_single_cat('parent');
echo get_single_cat('count');</pre>
<p>If the input type is not sent it will return the category ID, as default.</p>
<h2>Improvements</h2>
<p>Do you have any ideas, bugs, features or anything else to improve the code? Write a comment and I&#8217;ll look into it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devdevote.com/cms/wordpress-hacks/get_single_cat/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>get_user()</title>
		<link>http://www.devdevote.com/cms/wordpress-hacks/get_user</link>
		<comments>http://www.devdevote.com/cms/wordpress-hacks/get_user#comments</comments>
		<pubDate>Sat, 16 Jan 2010 14:51:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Wordpress hacks]]></category>

		<guid isPermaLink="false">http://www.devdevote.com/?p=35</guid>
		<description><![CDATA[Wordpress have a built in function called get_currentuserinfo. A global variable is set. It calls a function to get the user information. It then echos the username. The code is not as short and easy as it could be.]]></description>
			<content:encoded><![CDATA[<h3 class="red">The problem</h3>
<p>WordPress have a built in function called <a title="get_currentuserinfo" href="http://codex.wordpress.org/Function_Reference/wp_get_current_user">get_currentuserinfo</a>. It&#8217;s can be used like this example.</p>
<pre>global $current_user;
get_currentuserinfo();
echo $current_user-&gt;user_login;</pre>
<p>A global variable is set. It calls a function to get the user information. It then echos the username. The code is not as short and easy as it could be.</p>
<h3 class="green">The solution</h3>
<p>I created a function that returns a value depending of the input type. Put the function into your functions.php in your theme folder.</p>
<pre>function get_user($type = 'ID')
{
     global $current_user;
     get_currentuserinfo();

     switch ($type)
     {
          case 'ID':
               return $current_user-&gt;ID;
               break;
          case 'displayname':
               return $current_user-&gt;display_name;
               break;
          case 'username':
               return $current_user-&gt;user_login;
               break;
          case 'firstname':
               return $current_user-&gt;user_firstname;
               break;
          case 'lastname':
               return $current_user-&gt;user_lastname;
               break;
          case 'level':
               return $current_user-&gt;user_level;
               break;
          case 'email':
               return $current_user-&gt;user_email;
               break;
          default:
               return;
     }
}</pre>
<h3>The function call</h3>
<p>Call the function inside the post loop somewhere in your theme. The example below prints out all the current user information.</p>
<pre>echo get_user('ID');
echo get_user('displayname');
echo get_user('username');
echo get_user('firstname');
echo get_user('lastname');
echo get_user('level');
echo get_user('email');</pre>
<p>If the input type is not sent it will return the category ID, as default.</p>
<h2>Improvements</h2>
<p>Do you have any ideas, bugs, features or anything else to improve the code? Write a comment and I&#8217;ll look into it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devdevote.com/cms/wordpress-hacks/get_user/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>wp_list_categories() WITH current_cat_ancestor</title>
		<link>http://www.devdevote.com/cms/wordpress-hacks/wp_list_categories-with-current_cat_ancestor</link>
		<comments>http://www.devdevote.com/cms/wordpress-hacks/wp_list_categories-with-current_cat_ancestor#comments</comments>
		<pubDate>Sat, 16 Jan 2010 14:50:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Wordpress hacks]]></category>

		<guid isPermaLink="false">http://www.devdevote.com/?p=33</guid>
		<description><![CDATA[Wordpress have a "bug". It doesn't add a current_cat_ancestor class to the wp_list_pages function. If you need it, you can use the code below.]]></description>
			<content:encoded><![CDATA[<p>WordPress have a &#8221;bug&#8221;. It doesn&#8217;t add a current_cat_ancestor class to the wp_list_pages function. If you need it, you can use the code below.</p>
<pre>function wp_list_categories2($args = '')
{
global $cat;
if($args == '')
$wp_list_categories = wp_list_categories();
else
$wp_list_categories = wp_list_categories($args);

$cat_id_cut1 = explode('cat-item-', $wp_list_categories);

for($i=1; $i&amp;lt;sizeof($cat_id_cut1); $i++)
{
$cat_id_cut2 = explode('"&amp;gt;&amp;lt;a', $cat_id_cut1[$i]);
$category_id_array[] = $cat_id_cut2[0];
}

for($i=0; $i&amp;lt;sizeof($category_id_array); $i++)
{
if(is_numeric($category_id_array[$i]))
{
if(cat_is_ancestor_of( $category_id_array[$i], $cat))
{
$wp_list_categories = str_replace($category_id_array[$i], $category_id_array[$i] . ' current-cat-ancestor', $wp_list_categories);
}
}
}
return $wp_list_categories;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.devdevote.com/cms/wordpress-hacks/wp_list_categories-with-current_cat_ancestor/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Use SQL-querys in the loop &#8211; WITH template tags</title>
		<link>http://www.devdevote.com/cms/wordpress-hacks/use-sql-querys-in-the-loop-with-template-tags</link>
		<comments>http://www.devdevote.com/cms/wordpress-hacks/use-sql-querys-in-the-loop-with-template-tags#comments</comments>
		<pubDate>Sat, 16 Jan 2010 14:35:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Wordpress hacks]]></category>

		<guid isPermaLink="false">http://www.devdevote.com/?p=21</guid>
		<description><![CDATA[I want to use SQL-querys within the Wordpress loop and still be able to use the template tags. Here is the solution.]]></description>
			<content:encoded><![CDATA[<h3 class="red">The problem</h3>
<p>I want to use SQL-querys within the WordPress loop and still be able to use the template tags. In this example I want both posts and pages within the loop. How can I do that? In both query_posts and WP Query I can only get specific posts OR pages, not both.</p>
<p>I&#8217;ve been searching the web for a way to combine multiple WP Query objects somehow, because I only want one loop.</p>
<h3 class="green">The solution</h3>
<p>The solution is by not using WP Query at all. This is how it works:</p>
<ol>
<li>Write a SQL Query. This gives you a great freedom to just select the post / pages you need, or a combination of them.</li>
<li>Create a result object by using the function get_results.</li>
<li>If I get a result, loop it out in a foreach loop.</li>
<li>Use the function setup_postdata to be able to use WordPress template tags.</li>
</ol>
<pre>&lt;?php
$query_sql = "
     SELECT *
     FROM $wpdb-&gt;posts
     WHERE post_type = 'post'
     OR post_type='page'
     ORDER BY post_title DESC
";

$query_result = $wpdb-&gt;get_results($query_sql, OBJECT);
?&gt;

&lt;?php if ($query_result): ?&gt;
     &lt;?php foreach ($query_result as $post): ?&gt;
          &lt;?php setup_postdata($post); ?&gt;
          &lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt;
          &lt;?php the_content(); ?&gt;
     &lt;?php endforeach; ?&gt;
&lt;?php else : ?&gt;
     &lt;p&gt;Not found&lt;/p&gt;
&lt;?php endif; ?&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.devdevote.com/cms/wordpress-hacks/use-sql-querys-in-the-loop-with-template-tags/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Get ID by post or page name</title>
		<link>http://www.devdevote.com/cms/wordpress-hacks/get-id-by-post-or-page-name</link>
		<comments>http://www.devdevote.com/cms/wordpress-hacks/get-id-by-post-or-page-name#comments</comments>
		<pubDate>Sat, 16 Jan 2010 14:33:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Wordpress hacks]]></category>

		<guid isPermaLink="false">http://www.devdevote.com/?p=17</guid>
		<description><![CDATA[What I don’t like with wp_list_pages is that you can't exclude or include pages by NAME. Only by ID is available. Here is the solution.]]></description>
			<content:encoded><![CDATA[<p>If you use WordPress as CMS tool or are into making plugins you might have used the wp_list_pages function? I think it’s a good function but what I don’t like is that you can exclude or include pages with the ID and not by NAME. I however found a solution. Enjoy!</p>
<h2>Normal use</h2>
<p>This is the normal way of using the wp_list_pages function. It uses the ID for the page.</p>
<pre>wp_list_pages('include=5');</pre>
<h2>Extended use 1</h2>
<p>The nice thing about this is that you don’t need to know the ID of the page, it looks it up for you. You only need the post name and the ID is stored into the string. Then it writes it on the screen.<br />
<em>$my_id</em> is the string and <em>my_post_or_page_name</em> is the post or page name (which you need to change to your post or page name).</p>
<pre>$my_id = $wpdb-&gt;get_var("SELECT ID FROM $wpdb-&gt;posts WHERE post_name = 'my_page_or_page_name'");
echo $my_id;</pre>
<h2>Extended use 2</h2>
<p>This is very much like the first one but here I show how to use it. I use wp_list_pages with the string <em>$my_id</em> instead of a number. You only need to replace <em>my_post_or_page_name with</em> your own post or page.</p>
<pre>$my_id = $wpdb-&gt;get_var("SELECT ID FROM $wpdb-&gt;posts WHERE post_name = 'my_page_or_page_name'");
wp_list_pages('include='.$my_id);</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.devdevote.com/cms/wordpress-hacks/get-id-by-post-or-page-name/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

