[wp-hackers] Insert stuff into the excerpt based on a custom field, wipe out custom field

Matthew Gerring mgerring at emrl.com
Thu Sep 24 23:24:04 UTC 2009

In case anyone's interested, here was my solution. It's kind of a neat  
thing, I think:

function scc_yt($content)
$yt = get_post_meta($_POST['ID'], 'yt', TRUE);
if ($yt!="") {
	$qs = parse_url($yt);
	$lnk = '<a href="http://www.youtube.com/v/'.$v.'"><img src="http://img.youtube.com/vi/'.$v.'/0.jpg 
" alt="" /></a>';
	$content = $lnk;
	delete_post_meta($_POST['ID'], 'yt');
	return $content;


In conjunction with Shadowbox JS, this turns a raw YouTube link into  
clickable thumbnails that open the video in an overlay.

Working great now, thanks!

On Sep 24, 2009, at 12:47 PM, Matt Martz wrote:

> On Thu, Sep 24, 2009 at 03:44:28PM -0400, Matt Martz wrote:
>> The problem is that you are hooking save_post and performing a
>> wp_update_post within the callback.  wp_update_post causes the  
>> save_post
>> action to be fired again and thus you are creating a processing loop.
> using a filter probably content_save_pre and filtering the content
> before it is saved to the DB would be a better choice.
> -- 
> Matt Martz
> matt at sivel.net
> http://sivel.net/
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list