Skip Navigation

[Resolved] Create a playlist that uses the audio files from a Types Repeating Field

This support ticket is created 6 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 6 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#599555

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

#599643

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.