Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 134700

digitalrenewal on "Custom post type TAXONOMY prev/next links - by tax/category"

$
0
0

I have created a custom post type (products) with dynamic category taxonomies that the client sets up in wordpress.
Im trying to 'drill down' like this:

all categories (home.php) > all products in category (taxonomy.php) > single (single-products.php)

and when you get to a single product, I set it up to cycle through all products in the current category.

Its all working, except when you click the prev or next post_link, it just clicks through all categories, in order each product was published.

Is there a way to contain the pagination to the current taxonomy, and start/stop at the end of the posts in that category?

heres my code:

$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query(array(
'post_type'=>'products',
'taxonomy'=> 'product_categories',
'paged' => $paged,
'posts_per_page' => 1,
));

while ($wp_query->have_posts()) : $wp_query->the_post();

the_post_thumbnail( 'single' );
previous_posts_link('« Previous');
$terms = wp_get_post_terms( $post->ID, 'product_categories');
	foreach ($terms as $term) {
	echo '<a href="'.get_term_link($term->slug, 'product_categories').'">'.$term->name.'</a>';
	}
next_posts_link('Next &raquo;');

the_title();
the_content();
endwhile; 

$wp_query = null;
$wp_query = $temp;  // Reset

IM SO CLOSE!


Viewing all articles
Browse latest Browse all 134700

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>