<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; ">
<div>Sorry I can't help, but you might also get a good response from Stackexchange.com's wordpress thread. </div>
<div><br>
</div>
<div><a href="http://wordpress.stackexchange.com/">http://wordpress.stackexchange.com/</a></div>
<div><br>
</div>
<div>That way, your answer will be preserved for the rest of the WP community to draw from as well – not just the weasels in this group ;-)</div>
<div><br>
</div>
<div>Thx – Steve</div>
<div><br>
</div>
<div>
<div>
<div>
<div style="font-size: 14px; ">-- </div>
<div style="font-size: 14px; "><b>Steve Covello</b></div>
<div style="font-size: 14px; ">Rich Media Specialist/Online Instructor</div>
<div style="font-size: 14px; ">Chalk & Wire Administrator</div>
<div style="font-size: 14px; ">Granite State College</div>
<div style="font-size: 14px; ">603-513-1346</div>
<div style="font-size: 14px; ">Skype: steve.granitestate</div>
<div style="font-size: 14px; ">Scheduling: <a href="http://meetme.so/stevecovello">http://meetme.so/stevecovello</a></div>
<div style="font-size: 14px; "><br>
</div>
</div>
</div>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span><Charles>, Kimberly <<a href="mailto:kbaxa@uic.edu">kbaxa@uic.edu</a>><br>
<span style="font-weight:bold">Reply-To: </span>"Low-traffic list discussing WordPress in education." <<a href="mailto:wp-edu@lists.automattic.com">wp-edu@lists.automattic.com</a>><br>
<span style="font-weight:bold">Date: </span>Tuesday, September 24, 2013 4:32 PM<br>
<span style="font-weight:bold">To: </span>"Low-traffic list discussing WordPress in education." <<a href="mailto:wp-edu@lists.automattic.com">wp-edu@lists.automattic.com</a>><br>
<span style="font-weight:bold">Subject: </span>[wp-edu] Need help with code to select right image<br>
</div>
<div><br>
</div>
<div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; ">
<div>Hello --</div>
<div><br>
</div>
<div>I need help with some custom code for my WordPress site. I have a site that has 2 multimedia post types:</div>
<div>
<div>$media_type = 'audio';</div>
<div>$media_type = 'video';</div>
<div>and the site should pull the youtube thumbnail for the 'video' type and the post thumbnail for the 'audio' type, however, there isn't any if/else statement to distinguish between the two types for what image to use (this was built by someone else and I'm
trying to fix it).</div>
<div><br>
</div>
<div>I'm not sure (a.) if I should have the function inside functions.php do this or if (b.) it should be at the page template level.</div>
<div><br>
</div>
<div>This is what I have in functions.php -- which tells WP to get one thing for 'video' but doesn't tell it what to do for 'audio'</div>
<div><br>
</div>
<div>function abc_media_thumbnail() { ?></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span><div class="thumb"></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <!-- RUN TIME, CAST, etc... --></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <a>"></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <?php $media_type = 'video';</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> get_youtube_thumbnail(get_field('media_url'));</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> $runtime = get_field('length');</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> ?></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> </a></div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <?php if (!empty($runtime)): ?></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <span class="Apple-tab-span" style="white-space:pre"></span><div class="runtime"><?php echo $runtime; ?></div></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <?php endif; ?></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <div class='media-info'></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <p class='title'><a>"> <?php the_title(); ?></a></p></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <p class="date grayed"><?php the_time('F j, Y'); ?></p></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> </div></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span></div></div>
<div><?php</div>
<div>}</div>
<div><br>
</div>
<div>This is what the page template has:</div>
<div><br>
</div>
<div><?php get_header();</div>
<div>$url = get_bloginfo('url'); ?></div>
<div><br>
</div>
<div><div id="content"></div>
<div> <?php if ( have_posts() ) while ( have_posts() ): the_post(); ?></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <?php</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <span class="Apple-tab-span" style="white-space:pre"></span>$media_terms = get_the_terms($post->ID, 'media-type');</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <span class="Apple-tab-span" style="white-space:pre"></span>if (is_array($media_terms)) {</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <span class="Apple-tab-span" style="white-space:pre"></span>$media_type = array_pop($media_terms);</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <span class="Apple-tab-span" style="white-space:pre"></span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> ?></div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <?php if (isset($media_type)): ?></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <div class="labels"></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <a>slug; ?>"><?php echo $media_type->name; ?></a></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> </div></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <div id="media" class="clearfix"></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <?php</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> if ($media_type->slug == 'video') {</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> abc_video_post();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> } else {</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> abc_audio_post();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> }</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> ?></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> </div></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <?php endif; ?></div>
<div> <?php endwhile;</div>
<div> wp_reset_postdata();</div>
<div> ?></div>
<div><br>
</div>
<div> <?php if (isset($media_type)): ?></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <h2 class="recent">Recently Featured</h2></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> <?php</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> $args = array(</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> 'posts_per_page' => 4,</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> 'post__not_in' => array($post->ID),</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> 'tax_query' => array(</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> array(</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> 'taxonomy' => 'media-type',</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> 'field' => 'slug',</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> 'terms' => $media_type->slug</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> )</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> )</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> );</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> $recent_posts = new WP_Query( $args );</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> if ( $recent_posts->have_posts() ) while ( $recent_posts->have_posts() ): $recent_posts->the_post();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> abc_media_thumbnail();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> endwhile; ?></div>
<div> <?php endif; ?></div>
<div></div></div>
<div><?php get_sidebar(); ?></div>
<div><?php get_footer(); ?></div>
</div>
<div><br>
</div>
<div>Any help is much appreciated!</div>
<div>Kim</div>
</div>
</div>
</span>
</body>
</html>