WordPress.org

Ready to get started?Download WordPress

Forums

Next_Posts_Link() Leads to 404 (1 post)

  1. Howdy_McGee
    Member
    Posted 11 months ago #

    On my index.php page I'm trying to show a limited amount of my custom post type 'products', and for some reason I can't seem to get the next and previous links to work. They work fine on the single.php page. It's what I click a products category (which is a taxonomy):

    function product_category_taxonomy() {
    	$labels = array(
    		'name'              => __( 'Product Categories' ),
    		'singular_name'     => __( 'Product Category' ),
    		'search_items'      => __( 'Search Product Categories' ),
    		'all_items'         => __( 'All Product Categories' ),
    		'parent_item'       => __( 'Parent Product Category' ),
    		'parent_item_colon' => __( 'Parent Product Category:' ),
    		'edit_item'         => __( 'Edit Product Category' ),
    		'update_item'       => __( 'Update Product Category' ),
    		'add_new_item'      => __( 'Add New Product Category' ),
    		'new_item_name'     => __( 'New Product Category' ),
    		'menu_name'         => __( 'Product Categories' ),
    	);
    	$args = array(
    		'labels' => $labels,
    		'hierarchical' 	=> true
    	);
    	register_taxonomy( 'product-category', 'products', $args );
    }
    add_action( 'init', 'product_category_taxonomy');

    I have to do a custom query right under get_header()

    $paged = ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1;
    	$products = new WP_Query(array(
    		'post_type'		=>		'products',
    		'posts_per_page'=>		2,
    		'paged'			=>		$paged
    	));

    My navigation looks like this:

    <div class="alignleft"><?php next_posts_link('&laquo; Older Entries', '1000') ?></div>
    			<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;', '1000') ?></div>

    The 'Older Entries' link just leads to a 404 page and I can't figure out why. What could the possibilities be?

Reply

You must log in to post.

About this Topic