[wp-hackers] Newbie Q - can't get get_children to work

Gaarai gaarai at gaarai.com
Sat Apr 11 19:15:25 GMT 2009


If you want to attach the same image to numerous posts, using get_child 
for this is the wrong way to go. As you've noted, an attachment can 
have, at most, one parent.

Am I correct in that you simply need to get the attachment details given 
a specific file name?

Chris Jean
http://gaarai.com/
http://wp-roadmap.com/



Jan Erik Moström wrote:
> On 09-04-11 at 20.54, scribu <scribu at gmail.com> wrote:
>
>> An image is attached to a post if it has the post's id is in the
>> "post_parent" column in the wp_posts DB table, not if the URL is in the
>> post.
>
> When does that column get filled in?
>
> From my experiments it only seem to happen when I put a URL to the 
> image in a post.
>
> (note that I'm doing this from a blog editor that first uploads the 
> image and then allows me to use the URL to this image)
>
> Also, I took a quick look at the database schema - am I correct that 
> that each image can have one parent? What happens if I use one picture 
> in two different posts, will I be able to find the image using 
> get_child from both these posts?
>
>                 jem


More information about the wp-hackers mailing list