I would like to add a Playlist shortcode to a view that pulls the audio files from a repeating field.
I tried to modify this code: https://toolset.com/forums/topic/how-to-get-ids-of-repeating-images/
This gives me an array like: 62,63,64
function prefix_get_audio_ids($atts) {
$post_id= $atts["post_id"];
$songs = (array) get_post_meta($post_id, 'wpcf-song-sample', false); // cast to array in case there is only one item
$ids = array();
global $wpdb;
foreach($songs as $song) {
$query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$song'";
$id = $wpdb->get_var($query);
$ids[] = $id;
}
//[playlist images="false" artists="false" ids="[get-audio-ids post_id="[wpv-post-id]"]"]
return implode(",",$ids);
}
add_shortcode("get-audio-ids", "prefix_get_audio_ids");
But if I add a shortcode like this, it doesn't display:
[playlist images='false' ids="[get-audio-ids post_id="[wpv-post-id]"]"]
Any ideas what I'm doing wrong?
Thanks
Hi, it sounds like the get-audio-ids shortcode is working correctly when you place it by itself, but not working as an argument in another shortcode. Is "get-audio-ids" registered in Toolset > Settings > Frontend Content > 3rd Party Shortcode Arguments? It must be, and this step is easily overlooked if you're not familiar with it.