• Resolved shannonwall

    (@shannonwall)


    I’ve set up my template file for taxonomy-videocategory and it’s displaying the correct WordPress fields but I’m having trouble pulling a custom field image. With this code, it’s pulling the first thumbnail image attached to the first post but then the next post is the same thumbnail, even tho a different thumbnail is uploaded to that post.

    Right now, I’m testing the code with two different “views”. The first if statement works and pulls the right thumbnails but is displaying ALL posts and not posts just associated with the URL/ID of the term.

    The second is WordPress’s default template and works to pull the associated posts with the term BUT the thumbnails are the same when they should be different.

    <?php
    					//set find parameters
    					$params = array( 'limit' => 400 );
    					//get pods object
    					$pods = pods( 'video', $params );
    					//loop through records
    					if ( $pods->total() > 0 ) {
    					while ( $pods->fetch() ) {
    						//Put field values into variables
    						$title = $pods->display('name');
    						$url = $pods->field('vid_url');
    						$desc = $pods->field('vid_description');
    						$teaser = $pods->field('vid_teaser');
    						$thumb = $pods->field('vid_thumbnail');
    						$video_slug = $pods->get_field('permalink');
    				?>
    
    				<article>
    				<?php echo $title; ?>
    				<p><?php echo $teaser; ?></p>
    				<div id="image"><?php echo wp_get_attachment_image( $thumb['ID'], 'original' ); ?></div>
    				</article>
    
    				<?php
    					} //endwhile
    				} //endif
    
    				//do the pagination
    				echo $pods->pagination( array( 'type' => 'advanced' ) );
    				?>
    
    				<?php   if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    				<div id="video-library">
    					<article>
    						<a href="<?php echo get_permalink(); ?>" rel="bookmark"><?php echo wp_get_attachment_image( $thumb['ID'], 'original' ); ?></a>
    						<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
    							<?php the_title(); ?></a>
    						</h2>
    
    						<div class="entry-content" style="margin:15px 0 0;">
    							<?php the_excerpt(); ?><a href="<?php echo get_permalink(); ?>">Watch Video &raquo;</a>
    						</div>
    
    					</article>
    				</div>
    
    				<?php	endwhile;
    					else:
    						echo '<h3>'.__("Sorry! No post found.", 'ns_theme').'</h3>';
    					endif;
    				?>

    Any help appreciated, I’ve been banging my head for days trying to get this to work 🙂

    https://wordpress.org/plugins/pods/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Taxonomy Template PHP Help’ is closed to new replies.