[wp-hackers] Default thumbnails for a custom post type

Anca Mosoiu anca at anca.tv
Sat Aug 25 17:02:40 UTC 2012


Hi Carl,

Take a look at the 'wp_insert_post_data' filter - that lets you look at the data 
submitted before the post is first added.

You could also add an action on "save_post"  as well.

Anca.


On Aug 25, 2012, at 5:00 AM, Carl Russmann <crussmann at gmail.com> wrote:

> Date: Fri, 24 Aug 2012 09:18:38 -0700
> From: Carl Russmann <crussmann at gmail.com>
> Subject: [wp-hackers] Default thumbnails for a custom post type
> To: wp-hackers at lists.automattic.com
> Message-ID:
> 	<CAFe_rR-WEOhse_xifP-JBOFpVe-YqHdYKasccbjzNC5zSZs=wA at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
> 
> For the second time in as many months, I've found myself needing to set a
> few defaults when creating a custom post type. Setting a default title and
> content are straight-forward using the default_content and default_title
> filters.
> 
> Is there a simple way to set a default thumbnail when the "New Post" UI
> appears for the user?
> 
> What I've done for now is put this code into my filter for default_content.
> If $post->ID isn't 0, set_post_thumbnail(...) is called, along with any
> other post meta I'm setting as defaults on the new CPT. This seems to work,
> but feels like the hack that it is.
> 
> I've been tracing through core, but can't see any other hooks or filters
> that would be a more appropriate place to do this. Does anyone have any
> suggestions  or a better way to do this?
> 
> Thanks a lot!
> Carl



More information about the wp-hackers mailing list