jPlayer を WordPress サイトに組み込む作業を行っています。私たちのクライアントは技術的に少し不足しているため、利用可能な 2 つのプラグインは特に気にしません。ここで達成しようとしているのは、タイトルと 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>