Get individual value from a Post or Page

 * for $value you can use any post field (i.e. post_description, post_title, etc.
function get_post_value($id_or_name, $value='post_title') {
	global $wpdb;
	if(is_int($id_or_name)) {
		$field = 'ID';
	} else {
		$field = 'post_name';
	$value = $wpdb->get_var("SELECT $value FROM $wpdb->posts WHERE $field = '".$post_name."'");
	return $value;

Removing .svn folders recursively

The easiest way I have found is to open the Terminal and remove a listing of the folders:

cd /Users/YourUserName/TheFolderWhereSVNFilesAre
rm -rf `find . -type d -name .svn`

NOTE: Make sure that you user the grave accent quote (located on the left of the number 1 key)

Getting the post thumbnail URL

You can use wp_get_attachment_image_src() to retrieve an object with the post thumbnail information.

include ('wp-blog-header.php');
$post_id = $_REQUEST['id'];
$img_id = get_post_thumbnail_id($post_id, $size = 'post-thumbnail', $attr = '' );
$image = wp_get_attachment_image_src( $img_id );

While methods such as get_the_post_thumbnail() returns an image tag (), wp_get_attachment_image_src() returns a numeric array with the thumbnail info:

  • $image[0] => url
  • $image[1] => width
  • $image[2] => height

You can also determine if a post has attachments by calling has_post_thumbnail(), which returns a Boolean (true or false)

Getting pages by meta_key value

The following example shows how to query posts that have a custom filed name color and the assigned value is red.

$red_pages  = query_posts('post_type=page&meta_key=color&meta_value=red&orderby=menu_order&order=ASC');