Created
February 14, 2014 10:26
-
-
Save illucent/8998898 to your computer and use it in GitHub Desktop.
ajax latest posts ( http://stackoverflow.com/questions/17738638/concatenate-arrays-from-foreach-loop-into-single-variable-of-nested-arrays )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function ajax_get_latest_posts(){ | |
| $attachments = get_children(array('post_parent' => $post->ID, | |
| 'post_status' => 'inherit', | |
| 'post_type' => 'attachment', | |
| 'post_mime_type' => 'image', | |
| 'order' => 'ASC', | |
| 'orderby' => 'menu_order ID')); | |
| $allimagesizes = array(); | |
| foreach($attachments as $att_id => $attachment) { | |
| $large_bg_url = wp_get_attachment_image_src($attachment->ID, 'background-large'); | |
| $medium_bg_url = wp_get_attachment_image_src($attachment->ID, 'background-medium'); | |
| $small_bg_url = wp_get_attachment_image_src($attachment->ID, 'background-small'); | |
| $imagesizes = array('background_large' => $large_bg_url[0], 'background_medium' => $medium_bg_url[0], 'background_small' => $small_bg_url[0]); | |
| $allimagesizes[] = $imagesizes; | |
| } | |
| return $allimagesizes; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment