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 see galleries are represented as separate post records with post_type = 'gallery' in the database.

How is this record (gallery) associated with a basic post (type = 'post') in the terms of database records?

share|improve this question
    
Does the gallery post type have its post_parent set? I believe that's how the attachment post type (ie, media attachments like PDFs, JPGs, etc) are "attached" to posts. (I don't have a WP database to hand, or I'd check it myself.) –  Pat J Jul 18 '13 at 2:32
add comment

1 Answer

If you have a custom post type called 'gallery', you should be able to find it fairly easy if you can browse the database directly with phpMyAdmin. You will see your database tables on the left side of phpMyAdmin. Click on your posts tables which will probably look like "wp_posts". This will display a list of tables. Click the search icon at the top. Scroll down to the post_type field and enter "gallery". Press enter or click the "Go" button below. This should result in a list of every custom post_type in your database. Click "edit" for any table you wish to view. There you will see all of the details such as the ID for this post or the post_parent, which may be what you are looking for.

I do not have a gallery post_type, but if I want to know which post and image is related to I can search for the image within the post_type 'attachment' and even refine my search by using the specific image ID if I know it. Then I can "edit" the image and find the post parent.

By the way, you can get the ID of an image, post or anything else by going to its edit page in the admin panel and looking at the url. You will see something like "post=xxx" where xxx is the post ID.

share|improve this answer
    
I know all of this, I am coder :) I asked where is in DB connection between post and connected gallery, I see 2 record in wp_posts, one with type post 2nd one with type gellery, but I can't find where are they connected. –  Dmytro Zarezenko Jul 17 '13 at 9:25
    
Why are you expecting two different post types to be associated within the database? Can you give an example of a way that a gallery post and a regular post are used together? –  RyanLoremIpsum Jul 17 '13 at 9:50
add comment

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.