Question

I am using WP-ecommerce to build a shop, and have a random product generator on the left and right sidebar. So the same product doesnt appear twice on the page, I have got the post id's from each product in the left sidebar, and excluded them from the product query in the right sidebar.

I am doing this using an array with array_push:

<?php $leftids = array(); ?>

<?php query_posts('post_type=wpsc-product&showposts=2&orderby=rand&wpsc_rand=i-want-this-product-to-be-random'); if (have_posts()) : while (have_posts()) : the_post(); ?>

<div style="display:none"><?php the_title(); ?></div>

<a href="<?php the_permalink();?>"><?php the_post_thumbnail('sidebarimg');?></a>

<h2><?php the_title(); ?></h2>

<?php  array_push($leftids, $post->ID); ?>
<?php echo $leftids[0]; ?>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?> 

The problem is I cant access this array when on a product page at all. It works fine on a normal wordpress page such as home or contact us.

Any ideas?

Thanks

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top