WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] custom post pagination (3 posts)

  1. Jerry1234
    Member
    Posted 9 months ago #

    I have the following code when however the next posts and the previuos posts links doesn't show on the page.

    <?php
    		$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
    		$product_posts = new WP_Query(
    			array (
    				'post_status' => 'publish',
    				'post_type' => 'product',
    				'post_per_page' => 2,
    				'paged' => $paged
    			)
    		);
    
    		if( $product_posts->have_posts() ) : while( $product_posts->have_posts() ) : $product_posts->the_post(); ?>
    			<div id="products">
    				<div class="center">
    					<div class="product-title">
    						<?php the_title(); ?>
    					</div> <!-- product-title -->
    					<div class="product-image">
    					<?php
    						if( has_post_thumbnail() ) {
    							set_post_thumbnail_size( 200 );
    							the_post_thumbnail();
    						}
    					?>
    					</div><!-- product-image -->
    					<div class="price">
    						<b>Price: </b><?php echo get_post_meta( get_the_ID(), 'price_text', true ); ?>
    					</div><!-- price -->
    					<div class="float-right">
    						<?php
    							$stock_meta = get_post_meta( get_the_ID(), 'stock_text', true );
    							if( $stock_meta > 0 ) {
    								echo '<span class="in-stock">In stock</span>';
    							}
    							if( $stock_meta <= 0 ) {
    								echo '<span class="out-of-stock">Out of stock</span>';
    							}
    						?>
    					</div><!-- float-right -->
    				</div><!-- center -->
    			</div> <!-- products -->
    		<?php endwhile; endif; ?>
    		<div class="clear-both"></div><!-- clear-both -->
      <div class="alignleft"><?php previous_posts_link('&laquo; Previous') ?></div>
      <div class="alignright"><?php next_posts_link('More &raquo;') ?></div>
  2. keesiemeijer
    moderator
    Posted 9 months ago #

  3. Jerry1234
    Member
    Posted 9 months ago #

    Well that was simple thank you so much! I really appreciate it :)

Reply

You must log in to post.

About this Topic