Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Single Post Template: Songs Single
- */
- //Pastebin Reference link: Coming Soon
- //Ref post links:
- // http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src
- // http://wordpress.org/support/topic/auto-use-first-image-in-post-as-featured-image
- // uses http://www.tipsandtricks-hq.com/wordpress-audio-music-player-plugin-4556
- function song_first_image( $postid ) {
- // not used in theme but kept on script just in case global function fails
- $args = array(
- 'numberposts' => 1,
- 'order' => 'ASC',
- 'post_mime_type' => 'image',
- 'post_parent' => $postid,
- 'post_status' => null,
- 'post_type' => 'attachment',
- );
- $attachments = get_children( $args );
- if ( $attachments ) {
- foreach ( $attachments as $attachment ) {
- $image_attributes = wp_get_attachment_image_src( $attachment->ID, 'Song_Single_Thumb' ) ? wp_get_attachment_image_src( $attachment->ID, 'Song_Single_Thumb' ) : wp_get_attachment_image_src( $attachment->ID, 'full' );
- echo '<img src="' . $image_attributes[0] . '" width="' . $image_attributes[1] . '" height="' . $image_attributes[2] .'">';
- }
- }
- }
- function song_single_image() {
- if ( is_singular() && has_post_thumbnail() ) {
- $img = genesis_get_image( array( 'format' => 'html', 'size' => the_post_thumbnail( 'Song_Single_Thumb' ), 'attr' => array( 'class' => 'aligncenter Song_Single_Thumb' ) ) );
- }
- }
- /** Customize the post info */
- add_filter( 'genesis_post_info', 'song_single_post_info' );
- function song_single_post_info($post_info) {
- //$post_info = '[post_date format="F j, Y"] by [post_author_posts_link before="<b>" after="</b>"]';
- $post_info = '[post_date format="F j, Y"]';
- return $post_info;
- }
- // Force content-sidebar layout setting
- add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
- remove_action( 'genesis_loop', 'genesis_do_loop' );
- add_action( 'genesis_loop', 'songs_single' );
- function songs_single() {
- $query_one = new WP_Query ( array( 'post_type' => 'song', 'posts_per_page' => '1' ) );
- ?>
- <?php genesis_before_post(); ?>
- <?php genesis_before_post_title();
- echo '<div itemscope itemtype ="http://schema.org/MusicRecording" class="songs">'; // echo out schema item type
- echo '<h1 itemprop="name">'; // echo out schema property
- echo ( get_the_title() ); // using post title as schema item property
- echo '</h1>'; ?>
- <?php genesis_after_post_title(); ?>
- <!--<?php song_single_post_info($post_info); ?>-->
- <?php genesis_before_post_content(); ?>
- <?php if ($query_one->have_posts()) : // custom query for primary post content
- $postid = get_the_id();
- $cats = get_the_category();
- $cat = $cats[0];
- $cat_id = $cat->cat_ID;
- $cat_name = $cat->name;
- $cat_slug = $cat->slug;
- $artist = get_the_author();
- $artistPostLink = the_author_posts_link();
- $artistNew = get_the_author_meta('display_name',get_queried_object()->post_author);
- $artistID = get_the_author_meta('ID',get_queried_object()->post_author);
- //$another_artist = get_the_author_meta('display_name');
- //Ref link: http://codex.wordpress.org/Function_Reference/the_author_meta
- //$songThumb = song_single_image();
- $i=0; // counter
- while ($query_one->have_posts()) : the_post(); $do_not_duplicate = $post->ID; ?>
- <?php if ($i == 0) {
- $artistPostLink = get_the_author_link();
- $artistPosts = get_the_author_posts(); ?>
- <div class="songs">
- <div itemprop="thumbnail" class="one-third first"><?php song_single_image(); ?></div>
- <div class="one-third second">
- <?php if ( get_post_meta($postid, '_songs_songFile', true) ) : // verify that custom data exists before output
- $songFile = ( get_post_meta($postid, "_songs_songFile", true) );
- echo '<span class="hrlabel">Listen to ' . get_the_title() . ' :</span>'; // section label
- //echo '<p class="audio">'; // echo out schema property
- echo '<div itemprop="audio" class="audio">';
- echo do_shortcode ( '[sc_embed_player fileurl="' . $songFile .'"]' );
- echo '</div>';
- endif; ?>
- <?php if ( get_post_meta($postid, '_songs_songArtist', true) ) : // verify that custom data exists before output
- echo '<p itemprop="byArtist" class="byArtist">'; // echo out schema property
- echo '<span class="hrlabel">Artist: </span>'; // section label
- echo ( get_post_meta($postid, "_songs_songArtist", true) ); // echo custom field
- echo '</p>';
- endif; ?>
- <?php if ( get_post_meta($postid, '_songs_songAlbum', true) ) : // verify that custom data exists before output
- echo '<p itemprop="inAlbum" class="inAlbum">'; // echo out schema property
- echo '<span class="hrlabel">From Album: </span>'; // section label
- echo ( get_post_meta($postid, "_songs_songAlbum", true) ); // echo custom field
- echo '</p>';
- endif; ?>
- </div>
- <div class="one-third">
- <?php if ( get_post_meta($postid, '_songs_songContributor', true) ) : // verify that custom data exists before output
- echo '<div class="contributor"><span class="hrlabel">Other Contributors:</span>'; // Echo out the div class & title
- echo '<span itemprop="contributor">'; // Echo Schema property
- echo wpautop( get_post_meta( $postid, "_songs_songContributor", true ) ); // Echo out other contributors entry
- echo '</span></div>'; //Close up itemprop span & div class
- endif; ?>
- </div>
- <?php echo '<div class="description" itemprop="description">'; // echo out schema property
- echo ( wpautop (the_content()) ); // using post content as song description, preserve paragraphs with wpautop
- echo '</div>';
- ?>
- </div>
- <?php $i++; ?>
- </div><!-- end .entry-content -->
- <?php }; ?>
- <?php rewind_posts(); ?>
- <?php if ($i == 1) { ?>
- <div id="accordion-single">
- <?php $shrt_cd = "[accordion title='All music from " . $artistNew . "']";
- $query_two = new WP_Query ( array ( 'post_type' => 'song', 'author' => $artistID, 'posts_per_page' => '-1' ) );
- $shrt_cd .= '<ul class="accordion-single-list">';
- if ($query_two->have_posts()) :
- while ($query_two->have_posts()) : $query_two->the_post();
- if( !$post->ID == $do_not_duplicate ) continue;
- $shrt_cd .= '<li><a href="'.get_permalink().'">';
- $shrt_cd .= get_the_title();
- $shrt_cd .= '</a></li>';
- endwhile; endif;
- $shrt_cd .= '</ul>';
- $shrt_cd .= "[/accordion]";
- echo do_shortcode( $shrt_cd );
- wp_reset_query();
- ?>
- </div><!-- accordion-single -->
- <?php $i++; ?>
- <?php if ($i == 2) {
- genesis_after_post_content();
- genesis_before_comments();
- genesis_after_comments();
- genesis_before_pings();
- genesis_after_pings();
- genesis_before_comment_form();
- genesis_comment_form();
- genesis_after_comment_form();
- } ?>
- <?php return $wp_query->current_post + 1 < $wp_query->post_count;?>
- <?php }; ?>
- <?php $i++; ?>
- <?php endwhile; ?>
- <?php genesis_after_endwhile(); ?>
- <?php endif; ?>
- <?php genesis_after_loop(); ?>
- <?php genesis_after_content_sidebar_wrap(); ?>
- <?php genesis_before_footer(); ?>
- <?php genesis_after_footer(); ?>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement