我正在努力将 jPlayer 整合到我们的 WordPress 网站中。我并不特别关心可用的两个插件,因为我们的客户在技术上有点不足。我们希望完成的是将标题和 Mp3 加载到 jPlayer 播放列表的 JavaScript 中。目前,一切都加载得很好并返回了适当的文本,但是我无法正确加载文件名和附件 URL。在这方面,我对 java 和 wordpress 还很陌生。如果您想查看实时站点示例,请访问http://www.ourgoodfight.com/?p=6054
<!--Begin Jplayer Playlist -->
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
new jPlayerPlaylist({
jPlayer: "#jquery_jplayer_1",
cssSelectorAncestor: "#jp_container_1"
}, [
<?php
global $post;
$jukebox_args = get_posts( array(
'post_type' => 'attachment',
'posts_per_page' => -1,
'post_mime_type' => 'audio/mpeg',
'orderby' => 'menu_order',
'order' => 'ASC',
'post_parent' => $post->ID
));
$the_jukebox_query = new WP_Query( $jukebox_args );
?>
<!--This is what needs to loop -->
<?php
$loop = new WP_Query( $jukebox_args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
{
title:<?php echo apply_filters( 'the_title', $attachment->post_title ); ?>,
mp3:<?php echo wp_get_attachment_url( $attachment->ID, false ); ?>,
},
<?php endwhile;?>
<!--This would be the end of the loop -->
], {
swfPath: "<?php echo get_template_directory_uri(); ?>/js",
supplied: "mp3",
wmode: "window"
});
});
//]]>
</script>