Support

Account

Home Forums General Issues Gallery values disappearing, trying to use get_post_meta Reply To: Gallery values disappearing, trying to use get_post_meta

  • I think I figured this out. Here’s the code I used to get the URL, credit and description field from the gallery field “photos”:

    
    $photosValues = get_post_meta( $post->ID, 'photos');
    	foreach ( $photosValues as $photoItem) { 
    		foreach ( $photoItem as $photoID) { 
    			$thePhoto = get_post($photoID);
    			$photoURL = wp_get_attachment_url($photoID); // gets photo URL
    			$photoCredit = get_field('credit', $photoID); // gets ACF credit field
    			$photoDesc = $thePhoto->post_content; // gets description field
    			echo $photoURL; 
    			echo $photoCredit; 
    			echo $photoDesc;	
    		} 
    	}