Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have this while loop in my product page with Wordpress e-commerce plugin. It is looping through custom post meta.

<?php if (wpsc_have_custom_meta()) : ?>
    <?php $count = 2; ?>
    <?php while ( wpsc_have_custom_meta() ) : wpsc_the_custom_meta(); ?>
    <?php if (stripos(wpsc_custom_meta_name(),'g:') !== FALSE) continue; ?>
    <li>
        <a href="#tab<?php echo $count; ?>"><?php echo wpsc_custom_meta_name(); ?></a>
    </li>
    <?php $count ++; ?>
<?php endwhile; ?>
<?php endif; ?>    

I repeat this twice. Once to iterate through tab titles and once through the tab body. But for some reason the second instance of the while loop won't work. If I delete the first instance then the second one works as expected but as soon as I have to examples of it then it no longer works. Thanks for the help.

share|improve this question

closed as off-topic by Pieter Goosen, Johannes Pille, s_ha_dum Oct 11 at 18:22

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

    
I have to assume the problem is with how those wpsc_* functions work. My guess is that they are looping over an array/object and not resetting at the end. As those are not core functions, though, this is going to be off-topic as being dependent upon third-party code. –  s_ha_dum Oct 11 at 18:22

1 Answer 1

up vote 0 down vote accepted

It doesn't appear possible to loop over the values multiple times without directly manipulating the current_custom_meta class var so that wpsc_have_custom_meta() will return true again. Give this a try before the second while loop:

global $wpsc_custom_meta;
$wpsc_custom_meta->rewind_custom_meta();
$wpsc_custom_meta->current_custom_meta = -1;
share|improve this answer
    
You are a wizard. Thanks! –  motleydev Feb 12 '13 at 17:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.