I wrote this Query:
$album_id = get_the_id();
$photos = $wpdb->get_results(
"select * from wp_postmeta where post_id = '"
. $album_id
. "' AND meta_key = 'gallery_ph' order by meta_id desc"
);
Now, I want to get all thumbnails with title, name and description for this images.
I found in the DB:
meta_id | post_id | meta_key | meta_value
577 | 346 | gallery_ph | http://url to the image
and the thumbnail
meta_id | post_id | meta_key | meta_value
569 | 348 | _wp_attachment_image_alt | Jury Datiop
How are this two datas connected? I know that Jury Datiop has the url http://xxx because I can check in wp-admin. But how to write the select query? How to connect image and get title, name, description?
You don’t need to query the database directly.
WordPress has a whole lot of custom functions for you to retrieve the data that you need.
Check the:
WordPress Codex : Function Reference
Specially:
get_postsget_childrenwp_get_attachment_metadataTranslation of your database query to a WordPress function:
code not tested, use the Debug to inspect the results of each operation