[wp-hackers] wp_get_attachment_url() checking for attachment post_type, really necessary?
otto at ottodestruct.com
Fri Nov 12 13:58:22 UTC 2010
A "post" should never have an attached file like that. Attachments get
their own post for them, with the post_type of "attachment" and other
metadata about the attachment stored in the post_meta. They're
connected to the original post via the post_parent.
Similarly, I can't think of a good reason for a custom post type to
have an attached file. It should have attachment posts hooked to it
instead. Without the attachment posts, there's no place to store the
specific meta information about the file.
On Fri, Nov 12, 2010 at 7:31 AM, Leo germani <leogermani at gmail.com> wrote:
> Hi all,
> in the wp_get_attachment_url() we have the following check
> if ( 'attachment' != $post->post_type || empty($url) )
> return false;
> I was wondering if we really need this check for attachment post_type. If
> the post have a "_wp_attached_file" postmeta record, isnt it enough?
> Now with custom post types I think we are going to have other post types
> that could behave as attachments. I do this with some "audio" post type,
> which are uploaded audio files by the user. But I cant use
> wp_get_attachment_url() because it will allways return false...
> What do you think?
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers