• I have a custom template for a taxonomy page called taxonomy-videocategory and I want to display ALL posts associated with each category and it’s only showing ten. I’ve tried several ways to do this via Google searching but with no luck. Below is my code, any help is appreciated! I was hoping for something simple that you just add to the WordPress loop starting out but that doesn’t seem to be the case? Thank you!

    <?php   if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    				<?php
    					//get pods object
    					$pods = pods( 'video', $params );
    				?>
    				<?php
    					if ( get_post_meta( get_the_ID(), 'vid_thumbnail', false ) ){
    				    $image_array = get_post_meta( get_the_ID(), 'vid_thumbnail', false );
    					}
    					if ( $image_array ) {
    				    foreach ( $image_array as $image ) {
    			        $thumbimg = wp_get_attachment_image( $image['ID'], 'full', 'original' );
    				    }
    					}
    				?>
    
    				<?php
    					$teaser= get_post_meta( $post->ID, 'vid_teaser', true );
    				?>
    
    				<div id="video-library">
    					<article>
    						<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php echo $thumbimg; ?></a>
    						<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
    							<?php the_title(); ?></a>
    						</h2>
    
    						<div class="entry-content" style="margin:15px 0 0;">
    							<p><?php echo $teaser; ?></p>
    							<a class="watchvideo" href="<?php the_permalink() ?>" rel="bookmark" title="Watch Video &raquo; <?php the_title_attribute(); ?>">Watch Video &raquo;</a>
    						</div>
    
    					</article>
    				</div>
    
    				<?php	endwhile;
    					else:
    						echo '<h3>'.__("Sorry! No post found.", 'ns_theme').'</h3>';
    					endif;
    				?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter shannonwall

    (@shannonwall)

    I found out how to do it! 🙂

    Below is the code I needed to add, from what I understand it doesn’t override the entire loop and adds in only what I want it to do which is display all the posts associated with the category being displayed. I just placed this chunk before the if loop.

    <?php
    					//get the $query_string in to your $args array
    					global $query_string;
    					parse_str( $query_string, $args );
    					//modify whatever you want
    					$args['posts_per_page'] = -1;
    					query_posts($args);
    				?>

    Just wanted to share in case anyone else needed a simple solution.

    $args[‘posts_per_page’] = -1;

    “-1” might prove very inefficient, I don’t know how you call it later – for example if infinite jquery frontend (pre)loading, but in general it is advisable to set some limit (in case you have like 200 posts to load on jquery after…) plus all mysql databases and php servers have default timeout that can be a problem in traffic spikes.

    Try a large fixed number like 50 or 100 but never -1, it means infinite ressources on cpu and memory, which you may not have on vps or rather cheap solutions – it can lead to page or server crash later.

    Regards

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘display all posts in taxonomy template’ is closed to new replies.