Advertisement
marjwyatt

Genesis Custom Portfolio Single

Sep 8th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.59 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Single Post Template: Portfolio Single
  4.  */
  5. //Pastebin Reference link: Coming Soon
  6. //Ref post links:
  7. // http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src
  8. // http://wordpress.org/support/topic/auto-use-first-image-in-post-as-featured-image
  9. // uses http://www.tipsandtricks-hq.com/wordpress-audio-music-player-plugin-4556
  10. // http://www.billerickson.net/code/wp_query-arguments/
  11. // http://justintadlock.com/archives/2010/07/10/meta-capabilities-for-custom-post-types
  12. // http://codex.wordpress.org/Function_Reference/the_author_meta
  13. // http://codex.wordpress.org/Function_Reference/get_the_author_meta
  14. // http://codex.wordpress.org/Function_Reference/get_author_posts_url
  15. // http://codex.wordpress.org/Function_Reference/do_shortcode
  16. // http://codex.wordpress.org/Function_Reference/wp_video_shortcode
  17. // http://codex.wordpress.org/Video_Shortcode
  18. // http://codex.wordpress.org/Function_Reference/wp_audio_shortcode
  19. // http://codex.wordpress.org/Audio_Shortcode
  20. // http://oembed.com/
  21. // http://codex.wordpress.org/Function_Reference/wp_oembed_get
  22. // http://wordpress.org/support/topic/oembed-and-custom-field
  23. // http://codex.wordpress.org/Function_Reference/get_the_tags
  24.  
  25. function portfolio_single_image() {
  26.     if ( is_singular() && has_post_thumbnail() ) {
  27.         $img = genesis_get_image( array( 'format' => 'html', 'size' => the_post_thumbnail( 'Home Featured' ), 'attr' => array( 'class' => 'aligncenter Home Featured' ) ) );
  28.     }
  29. }
  30.  
  31. // Force content-sidebar layout setting
  32. add_filter( 'genesis_site_layout', '__genesis_return_sidebar_content' );
  33.  
  34. //* Remove the post info function
  35. remove_action( 'genesis_before_post_content', 'genesis_post_info' );
  36.  
  37. $postDate = do_shortcode ('[post_date]'); //reference only
  38. $postComments = do_shortcode ('[post_comments]'); //reference only
  39. $postEdit = do_shortcode ('[post_edit]'); //reference only
  40.  
  41. remove_action( 'genesis_loop', 'genesis_do_loop' );
  42. add_action( 'genesis_loop', 'arts_single' );
  43. function arts_single() {
  44.     //global $paged;
  45.     //global $loop_counter;
  46.     //$loop_counter = 0;
  47.     //global $post;
  48.     //$oldpost = $post;
  49.     $args = array(
  50.         'posts_per_page' => 1,
  51.         'post_type' => 'portfolio',
  52.         //'paged' => get_query_var( 'post' ),
  53.     );
  54.     global $my_query;
  55.     $my_query = new WP_Query ( $args );
  56.     genesis_before_post();
  57.     genesis_before_post_title();
  58.     echo '<div class="portfolio-content" itemscope itemtype="http://schema.org/CreativeWork">';  // echo out schema item type
  59.         echo '<h1 class="entry-title" itemprop="name">'; // echo out schema property
  60.         echo ( get_the_title() ); // using post title as schema item property
  61.         echo '</h1>';
  62.     genesis_after_post_title();
  63.     genesis_before_post_content();
  64.     if ($my_query->have_posts()) : // custom query for primary post content
  65.         //$queried_object = get_queried_object();
  66.         //var_dump( $queried_object );
  67.         $postid = get_the_id();
  68.         $postID = get_queried_object()->ID;
  69.         $cats = get_the_category();
  70.         $cat = $cats[0];
  71.         $cat_id = $cat->cat_ID;
  72.         $cat_name = $cat->name;
  73.         $cat_slug = $cat->slug;
  74.         $posttags = get_the_tags();
  75.         $postOembed = ( get_post_meta($postid, '_arts_projectEmbed', true) );
  76.     while ($my_query->have_posts()) : $my_query->the_post(); /*$do_not_duplicate = $post->ID;*/
  77.         // for some reason I had to do this to make the loop work:
  78.         // http://wordpress.stackexchange.com/questions/30694/manually-set-global-post-vars-with-an-id-in-order-to-use-template-tags
  79.         // another ref link: https://codex.wordpress.org/Function_Reference/setup_postdata
  80.         global $post;
  81.         /* Original working hack */
  82.         $post = get_post( $postID, OBJECT );
  83.         setup_postdata( $post );
  84.         $postWhileID = get_the_id();
  85.         $postNewWhileID = get_queried_object()->ID;
  86.         $artist = get_the_author();
  87.         $artistNickName = get_the_author_meta('nickname',get_queried_object()->post_author);
  88.         $artistPostLink = get_author_posts_url( get_the_author_meta( 'ID' ));
  89.         $artistNew = get_the_author_meta('display_name',get_queried_object()->post_author);
  90.         $artistID = get_the_author_meta('ID',get_queried_object()->post_author);
  91.         $artistPosts = get_the_author_posts();
  92.         echo '<div class="post-info">';
  93.         //echo '<p>Post While ID = '.$postWhileID.'</p>';
  94.         //echo '<p>Post Queried Object = '.$postNewWhileID.'</p>';
  95.         echo '<span class="date published time" title="'.do_shortcode ('[post_date]').'</span>';
  96.         echo '  by <a rel="author" href="' . $artistPostLink . '">' .$artist. '</a>';
  97.         echo do_shortcode ('[post_comments]');
  98.         echo '&nbsp;'.do_shortcode ('[post_edit]');
  99.         echo '</div>'; ?>
  100.         <?php echo '<div class="description" itemprop="description">'; // echo out schema property
  101.         //echo '<p>The Postid is: '.$postid.'</p>';
  102.         //echo '<p>The PostID is: '.$postID.'</p>';
  103.             echo ( wpautop (the_content()) ); // using post content as song description, preserve paragraphs with wpautop
  104.             echo '</div>';
  105.         ?>
  106.         <div class="one-third first" itemprop="image"><?php portfolio_single_image(); ?></div>
  107.         <!--<div class="one-third first" itemprop="image"><?php echo get_the_post_thumbnail($postid, 'Home Featured'); ?></div>-->
  108.         <div class="one-third second">
  109.         <!--<?php echo '<p>The post author is ' . $artist . '</p>'; ?>-->
  110.         <?php if ( get_post_meta($postID, '_arts_projectMP3', true) ) : // verify that custom data exists before output
  111.             $projectMP3 = ( get_post_meta($postID, "_arts_projectMP3", true) );
  112.             echo '<span class="hrlabel">Listen to ' . get_the_title($postID) . ' :</span>'; // section label
  113.             echo '<div itemprop="audio" class="audio">';
  114.             echo do_shortcode ( '[sc_embed_player fileurl="' . $projectMP3 .'"]' );
  115.             echo '</div>';
  116.         endif; ?>
  117.         <?php if ( get_post_meta($postID, '_arts_projectArtist', true) ) : // verify that custom data exists before output
  118.             echo '<p itemprop="creator" class="creator">'; // echo out schema property
  119.             echo '<span class="hrlabel">Artist:&nbsp;&nbsp;</span>'; // section label
  120.             echo ( get_post_meta($postID, "_arts_projectArtist", true) ); // echo custom field
  121.             echo '</p>';
  122.         endif; ?>
  123.         <?php if ( get_post_meta($postID, '_arts_projectAlbum', true) ) : // verify that custom data exists before output
  124.             echo '<p itemprop="inAlbum" class="inAlbum">'; // echo out schema property
  125.             echo '<span class="hrlabel">From Album:&nbsp;&nbsp;</span>'; // section label
  126.             echo ( get_post_meta($postID, "_arts_projectAlbum", true) ); // echo custom field
  127.             echo '</p>';
  128.         endif; ?>
  129.         </div><!-- end one-third second -->
  130.         <div class="one-third">
  131.         <?php if ( get_post_meta($postID, '_arts_projectContributors', true) ) : // verify that custom data exists before output
  132.             echo '<div class="contributor"><span class="hrlabel">Other Contributors:</span>'; // Echo out the div class & title
  133.             echo '<span itemprop="contributor">'; // Echo Schema property
  134.             echo wpautop( get_post_meta( $postID, "_arts_projectContributors", true ) ); // Echo out other contributors entry
  135.             echo '</span></div>'; //Close up itemprop span & div class
  136.         endif; ?>
  137.         </div><!-- end one-third -->
  138.         <?php if ( get_post_meta($postID, '_arts_projectEmbed', true) ) : // verify that custom data exists before output
  139.             echo '<span itemprop="video">'; // Echo Schema property
  140.             echo wp_oembed_get( get_post_meta($postID, '_arts_projectEmbed', true) );
  141.             echo '</span></div>'; //Close up itemprop span & div class
  142.         endif; ?>
  143.         <?php
  144.         //$loop_counter++;
  145.         //</div><!-- end two-thirds -->
  146.         //</div><!-- end portfolio content -->
  147.         //wp_reset_query();
  148.         genesis_after_post_content();
  149.         genesis_before_comments();
  150.         genesis_list_comments();
  151.         genesis_before_comment();
  152.         genesis_after_comment();
  153.         genesis_after_comments();
  154.         genesis_before_pings();
  155.         genesis_after_pings();
  156.         genesis_before_comment_form();
  157.         genesis_comment_form();
  158.         genesis_after_comment_form();
  159.         endwhile;
  160.         wp_reset_postdata();
  161.         genesis_after_endwhile();
  162.         endif;
  163.         genesis_after_loop();
  164.         genesis_after_content_sidebar_wrap();
  165.         //genesis_before_footer();
  166.        // genesis_after_footer();
  167. }
  168. //genesis();
  169. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement