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

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

IMPORTANT! To be able to proceed, you need to solve the following simple math (so I know that you are a human) :-)

What is 8 + 3 ?
Please leave these two fields as-is: