Support

Account

Home Forums Front-end Issues Field Values Not Showing in Custom Loop Reply To: Field Values Not Showing in Custom Loop

  • Thanks so much for your help! In the end I was able to do it by calling the default date and permalinks instead of adding a separate custom field for those.

    The result can be seen at http://nerdfit.com/videos

    The only problem I have now is that I can’t get pagination going with this custom post type archive. Is there any way I can show the “older entries” and “newer entries” links at the bottom of the loop?

    This is my code so far:

    <div class="wrap">
    
    	<?php 
    
    	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;		
    
    	$args = array( 
    		'post_type' => 'video',
    		'paged' => $paged,
    		'posts_per_page' => 9);
    
    	$query = new WP_Query( $args ); ?>
    
    	<?php if ( $query->have_posts()) : while ( $query->have_posts() ) : $query->the_post(); ?>
    
    			<div class="video-item">
    				<div class="video-image">	
    						<a href="<?php echo get_permalink(); ?>" ><?php the_post_thumbnail(); ?></a>
    
    				</div>
    			<h2><a href ="<?php echo get_permalink(); ?>" ><?php the_title(); ?></a></h2>
    			<h3><?php echo get_the_date(); ?></h3>
    
    			</div>
    		
    	<?php endwhile; ?>
    
    <?php
    
    // get_next_posts_link() usage with max_num_pages
    echo get_next_posts_link( 'Older Entries', $the_query->max_num_pages );
    echo get_previous_posts_link( 'Newer Entries' );
    ?>
    
    <?php 
    // clean up after the query and pagination
    wp_reset_postdata(); 
    ?>	
    
    <?php else: ?>
    
    	<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
    
    	<?php endif; ?>
    
    </div>
    
    </section>