I'm trying to get a list of attached images, I know this script works cause I've used it already a couple times for tags and categories in the feed. When I use it with attachments, it will NOT include the separator line. I have no idea why. Is there so some limit on how many times you can use this? I've tried renaming things to and nothing happens.
"image": [
<?php
$output = '';
$separator = ",";
$attachments = get_children(array('post_parent' => $post->ID,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order ID'));
if ($attachments) {
foreach($attachments as $att_id => $attachment) {
$output .= '"';
$output .= wp_get_attachment_url($attachment->ID);
$output .= '"';
}
echo trim($output,$separator);
}
?>
]
This is what I get.
"image": ["http://www.itsgametimela.com/wp-content/uploads/2015/10/sealed-deck-curve.png""http://www.itsgametimela.com/wp-content/uploads/2015/10/c4rd4rt_CsowW8oCu1.jpg"],
It will not toss in the comma to separate them. Any ideas?
After some digging came across this..
"image": [
<?php
$attachments = get_children(array('post_parent' => $post->ID,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order ID'));
if ($attachments) {
$output = array();
foreach($attachments as $att_id => $attachment) {
$output[] = '"'. wp_get_attachment_url($attachment->ID) . '"';
}
$image_list = implode(",",$output);
echo $image_list;
}
?>
]
I'll leave this answer here for anyone else who wants to attempt this.