• I’m having some trouble setting a specific number of custom posts for a given taxonomy to show, at current it will only show one posts, the code i am using to call and display the taxonomy is:

    <?php
    		$args = array(
    			'post_type' => 'product',
    			'tax_query' => array(
    				array(
    					'taxonomy' => 'product_category',
    					'field' => 'slug',
    					'terms' => 'all',
    
    				)
    			)
    		);
    		$products = new WP_Query( $args );
    		if( $products->have_posts() ) {
    			while( $products->have_posts() ) {
    				$products->the_post();
    				?>
    
    					<div class='content'>
    
    					</div>
    				<?php
    			}
    		}
    		else {
    			echo 'There seems to be a problem, please try searching again or contact customer support!';
    		}
    	?>
    
    <li>
    					<div class="allevents3-image">
    
    						<?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { ?>
    
    						<a>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a>
    
    						<?php } ?>
    
    					</div><!--category3-image-->
    
    					<div class="allevents3-text">
    
    						<a>" class="event-headline"><?php the_title(); ?></a>
                            <p></p>
                              <p></p>
    			<p><h2>Date: <?php the_field('event_date'); ?></h2></p>
                <p><h2>Venue: <?php the_field('event_venue'); ?></h2></p>
                <p><h4>Location: <?php the_field('event_location'); ?></h4></p>
    
                <div class="allevents3-exe">
                <p><?php echo excerpt(25); ?></p>
    
               <div class="view-info">
             <p><a>" rel="bookmark" title="<?php the_title(); ?>">View Event Info / Lineup</a></p>
    
            </div>
    	</div>
    
    					</div><!--category3-text-->
    
    </li>
    			  <?php if ( have_posts() ) : ?>
    <?php endif; ?>

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Use 'posts_per_page'=> -1 in array args to show all posts.

    Thread Starter lackie2k4

    (@lackie2k4)

    please excuse my lack of coding knowledge, but would this go here

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    <?php
    		$args = array(
    			'post_type' => 'product',
    			<strong>'posts_per_page'=> -1,</strong>
    			'tax_query' => array(
    				array(
    					'taxonomy' => 'product_category',
    					'field' => 'slug',
    					'terms' => 'all'
    				)
    			)
    		);
    		$products = new WP_Query( $args );
    		if( $products->have_posts() ) {
    			while( $products->have_posts() ) {
    				$products->the_post();
    				?>
    
    					<div class='content'>
    
    					</div>
    				<?php
    			}
    		}
    		else {
    			echo 'There seems to be a problem, please try searching again or contact customer support!';
    		}
    	?>

    yes, argument is on right place!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Taxonomy Trouble – Only displays one post at a time’ is closed to new replies.