Categories

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;
}

Get Post or Page by Name

$post_title = 'my-post-name';
$post = get_page_by_title($post_title, OBJECT);
var_dump($post);

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)

Truncate WordPress post content

$post_content = $post->post_content; // get the content
$post_content = strip_tags($post_content); // remove HTML tags
$post_content = preg_replace('/\[(.*)\]/', '', $post_content);  // remove shortcodes
$post_content = substr($post_content, 0, 30);
echo $post_content;