WordPress.org

Forums

Query Posts with Pagination (1 post)

  1. twelve2395
    Member
    Posted 3 years ago #

    Hi the following code will not display pages of results. I have 3,000+ products in a Custom Post Type. This code is loading the first 50 in a table, but is not giving the visitor a "next page" option.

    I've been going at this for 4 hours and after 30+ google searches I figured I would ask here. Does anyone know how to display the "Next Page" link under the table so that visitors can browse through all the pages of products

    Thanks so much in advance

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $the_query = new WP_Query(array('post_type' => 'product', 'orderby' => 'meta_value', 'meta_key' => 'stock_num', 'paged' => $paged, 'posts_per_page' => 50 ));
    } ?>
    
        <div id="single">
        <table id="results">
        	<tr class="header">
            <td>Stock Number</th>
            <td>info</th>
            <td>info</th>
            <td>info</th>
            <td>info</th>
    	<td>info</th>
            <td>Total Price</th>
    	</tr>
        <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
       	<?php $price = get_post_meta($post->ID, 'price', true);
    		$info = get_post_meta($post->ID, 'info', true);
    	 ?>
    
    	<tr>
            <td><?php echo get_post_meta($post->ID, 'stock_num', true); ?></td>
            <td><?php echo get_post_meta($post->ID, 'more_info', true); ?></td>
            <td><?php echo get_post_meta($post->ID, 'more_info1', true); ?></td>
            <td><?php echo get_post_meta($post->ID, 'more_info2', true); ?></td>
            <td><?php echo number_format($info, 2); ?></td>
            <td><?php echo get_post_meta($post->ID, 'more_info3', true); ?></td>
            <td><?php echo '$' . number_format($price, 2); ?></td>
    	</tr>
        <?php endwhile; else: endif; ?>
        </table>
        </div><!--End Single-->

Topic Closed

This topic has been closed to new replies.

About this Topic