1
votes

$loop = new WP_Query( array( 'post_type' => 'special_offers', >'posts_per_page' => -1 ) );

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

echo do_shortcode( '[my_special_offer_item]' );

endwhile;

wp_reset_query();`

my shortcode is not incrementing in the while loop in IE, Chrome & Safari, therefore they are all duplicates... but inside FF it works perfect.

1
What's the exact problem that you're having? (Would you mind to add that to the question, so that others may see it too?)Alpha
sorry alpha... basically my shortcode is not incrementing in the while loop in IE, Chrome & Safari, therefore they are all duplicates... but inside FF it works perfectthefonz

1 Answers

1
votes

Sorry to doubt you, but I do have a hard time believing that do_shortcode works differently based on the browser. Since this is PHP code, it is executed before it gets to the browser, and while the PHP code may actually do something different based on the user agent, it is very unlikely that is the case.

However, if there are any rendering issues with the shortcode itself, you may see something different in the browsers, but that's something closer to the template/theme itself rather than the code.

As for do_shortcode, please note that the Codex documentation (https://codex.wordpress.org/Function_Reference/do_shortcode) nor the source code (https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/shortcodes.php#L189) seem to be auto-incrementing in any way.

Maybe you're supposed to inject a dynamic variable into it to make different shortcode searches depending on the post? If so, check for variable string interpolation or just concatenation Here's an example (https://wordpress.org/support/topic/how-to-use-echo-do_shortcode-with-dynamic-variable)

<?php echo do_shortcode('[walkscore ws_wsid="example" ws_address="'.get_post_meta($post->ID, 'pyre_full_address', true).'"]'); ?>

I hope this helps.