[wp-hackers] get the excerpt in custom loop

Daiv Mowbray daiv at daivmowbray.com
Thu Oct 15 08:40:20 UTC 2009


Hello list,

I'm running through an array of attachments,
trying to pull certain elements from the attachments parent.
the function get_the_excerpt seams to be deprecated.

How can I pull the excerpt without it being echoed directly to the page?
This echos to page:
	$my_parent_excerpt = the_excerpt($my_parent);
as does this:
	$my_parent_excerpt = the_content_rss(); // can not pass the post ID  
to this

EXAMPLE:
foreach ( $all_attachments as $attachment ) {

			$my_parent = ($attachment->post_parent); 	// this works, returns  
the parent ID
			$parent_link = get_permalink($my_parent);	 // this works, returns  
the parent link
			$my_parent_title = get_the_title($my_parent);	// this works,  
returns the parent title
			$my_parent_excerpt = get_the_excerpt($my_parent); 	// this only  
works for the first item/attachment parent

$output = $my_parent_title;
$output .= $my_parent_excerpt;
echo $output;
}
TIA
----------
Daiv Mowbray
daiv at daivmowbray.com
----------




More information about the wp-hackers mailing list