Home › Forums › Add-ons › Gallery Field › How to extract the serialized array › Reply To: How to extract the serialized array
Yes, Something like this
//conection... bla bla bla or
global $wpdb;
$single ="SELECT DISTINCT
ID AS id,
post_title AS title,
(SELECT meta_value FROM ".$wpdb->posts." WHERE post_id = ID AND meta_key = 'images') AS images
FROM
".$wpdb->posts."
WHERE
post_status = 'publish' AND
post_type = 'property'
";
foreach($wpdb->get_results($single, OBJECT) as $rss) {
$img = $rss->images;
$gallery = unserialize( $img );
$images = implode(", ", $galeria);
$photos = "SELECT
meta_value AS photos
FROM
".$wpdb->postmeta."
WHERE
".$wpdb->postmeta.".meta_key = '_wp_attached_file' AND
".$wpdb->postmeta.".post_id IN($imagens)
";
foreach($wpdb->get_results($photos, OBJECT) as $rss) {
echo $rss->photos; // 2016/01/photo.jpg
}
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.