WordPress.org

Ready to get started?Download WordPress

Forums

Custom Taxonomy Trouble - Only displays one post at a time (4 posts)

  1. lackie2k4
    Member
    Posted 11 months ago #

    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.]

  2. Deepak Rajpal
    Member
    Posted 11 months ago #

    Use 'posts_per_page'=> -1 in array args to show all posts.

  3. lackie2k4
    Member
    Posted 11 months ago #

    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!';
    		}
    	?>
  4. Deepak Rajpal
    Member
    Posted 11 months ago #

    yes, argument is on right place!!

Reply

You must log in to post.

About this Topic