Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I know that media are an attachment post type that are children to a post, but how are galleries stored in WordPress?

share|improve this question
1  
You should ask the other way around: "Where does the gallery shortcode gets its attachments from?" ;) –  kaiser Oct 4 '12 at 15:15
    
@kaiser good point. I'm working on a gallery/album plugin and I'm doing research on how WordPress currently handles them. –  Manny Fleurmond Oct 4 '12 at 15:17

1 Answer 1

up vote 1 down vote accepted

This completely depends on how your gallery shortcode looks like.

If you replaced it with something custom, then you'll have to take a look at the plugin (or the theme).

The default gallery shortcode gets it from a query:

$query_args = array(
     'post_status'    => 'inherit'
    ,'post_type'      => 'attachment'
    ,'post_mime_type' => 'image'
    ,'order'          => $order
    ,'orderby'        => $orderby
);

Then it decides to add additional args for either include or exclude.

Here're the 3 scenarios that add the additional/non-shared arguments.

'include' => preg_replace( '/[^\D,]+/', '', $include )
'exclude' => preg_replace( '/[^\D,]+/', '', $include )
// default
'post_parent' => $id
share|improve this answer
    
As I thought. Thanks for the clarification. So basically galleries are just images that are attached to a post; 1 gallery per post and since images are children to a post, you can only really attach the images to just one post at a time. –  Manny Fleurmond Oct 4 '12 at 15:25
    
Not really. They're referenced in the post meta table. So every post with an image/a gallery has the attachment IDs in its meta data. –  kaiser Oct 4 '12 at 15:44
    
Oh, they are? Some more research to do. Thank you again, @kaiser –  Manny Fleurmond Oct 4 '12 at 15:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.