1

$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.

2
  • 2
    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?) Commented Jun 30, 2015 at 3:14
  • 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 perfect Commented Jun 30, 2015 at 3:41

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

appreciate that alpha.. i think im going the wrong way about it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.