Title: Problem with multiple shortcode in page template
Last modified: August 30, 2016

---

# Problem with multiple shortcode in page template

 *  [webtent](https://wordpress.org/support/users/webtent/)
 * (@webtent)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/problem-with-multiple-shortcode-in-page-template/)
 * I’ve been having a problem with a page that uses a template. The page (wmnf-events.
   php) has no content and the template for that page (page-wmnf-events.php) uses
   the following do_shortcode multiple times, once for each category-slug:
 *     ```
       <div id="wmnfevents">
       <?php echo do_shortcode('[ESPRESSO_EVENTS category_slug="wmnf-events" limit="20" title="WMNF Events" order_by="start_date,id" pagination="true"]'); ?>
       </div>
       <div id="communityevents">
       <?php echo do_shortcode('[ESPRESSO_EVENTS category_slug="community-events" limit="20" title="Community Events" order_by="start_date,id" pagination="true"]'); ?>
       </div>
       <div id="musicevents">
       <?php echo do_shortcode('[ESPRESSO_EVENTS category_slug="music-events" limit="20" title="Community Events" order_by="start_date,id" pagination="true"]'); ?>
       </div>
       <div id="nonprofitevents">
       <?php echo do_shortcode('[ESPRESSO_EVENTS category_slug="nonprofit-events" limit="20" title="Community Events" order_by="start_date,id" pagination="true"]'); ?>
       </div>
       ```
   
 * The reason I do this instead of listing all categories is to separate into different
   div tags and I use jQuery to show/hide depending on which category is selected
   from a drop down list. The page has been working fine for months and all of sudden
   it started repeating the same records (category-slug) in each div, in this case
   above it is listing the records for the wmnf-events category four times. If I
   switch out the category-slug to any of the others, it will display that category
   four times, like the query is not getting reset. If I put the code into a page
   like below, all works fine, showing the different records for each div:
 *     ```
       <div id=""wmnfevents"">[ESPRESSO_EVENTS category_slug="wmnf-events" limit="20″ title="WMNF Events" order_by="start_date,id" pagination="true"]</div>
       <div id=""communityevents"">[ESPRESSO_EVENTS category_slug="community-events" limit="20″ title="Community Events" order_by="start_date,id" pagination="true"]</div>
       <div id=""musicevents"">[ESPRESSO_EVENTS category_slug="music-events" limit="20″ title="Community Events" order_by="start_date,id" pagination="true"]</div>
       <div id=""nonprofitevents"">[ESPRESSO_EVENTS category_slug="nonprofit-events" limit="20″ title="Community Events" order_by="start_date,id" pagination="true"]</div>
       ```
   
 * Does anyone know what can cause this type of behavior? A really strange thing
   is the same page/template on our dev site works fine. But when I duplicated that
   page and template into test-events.php and page-test-events.php, then the problem
   exists in the page. I have checked all plugins and the WP versions on both sites
   to be exactly the same. I have also stripped all other code from the test template
   page including header and footer, still the issue exists.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/problem-with-multiple-shortcode-in-page-template/#post-6888291)
 * Try adding `wp_reset_postdata()` after each shortcode.
    [https://codex.wordpress.org/Function_Reference/wp_reset_postdata](https://codex.wordpress.org/Function_Reference/wp_reset_postdata)
 *     ```
       <div id="wmnfevents">
       <?php echo do_shortcode('[ESPRESSO_EVENTS category_slug="wmnf-events" limit="20" title="WMNF Events" order_by="start_date,id" pagination="true"]'); ?>
       <?php wp_reset_postdata(); ?>
       </div>
       <div id="communityevents">
       <?php echo do_shortcode('[ESPRESSO_EVENTS category_slug="community-events" limit="20" title="Community Events" order_by="start_date,id" pagination="true"]'); ?>
       <?php wp_reset_postdata(); ?>
       </div>
       <div id="musicevents">
       <?php echo do_shortcode('[ESPRESSO_EVENTS category_slug="music-events" limit="20" title="Community Events" order_by="start_date,id" pagination="true"]'); ?>
       <?php wp_reset_postdata(); ?>
       </div>
       <div id="nonprofitevents">
       <?php echo do_shortcode('[ESPRESSO_EVENTS category_slug="nonprofit-events" limit="20" title="Community Events" order_by="start_date,id" pagination="true"]'); ?>
       <?php wp_reset_postdata(); ?>
       </div>
       ```
   
 *  Thread Starter [webtent](https://wordpress.org/support/users/webtent/)
 * (@webtent)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/problem-with-multiple-shortcode-in-page-template/#post-6888305)
 * Yes, I tried that already with no help. Looking at the plugin that provides this
   shortcode, I also see they are using that and the wp_reset_query function as 
   well. It is very perplexing since I have one version on the dev site that works.
   Any attempts to recreate the page/template have the issue.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Problem with multiple shortcode in page template’ is closed to new replies.

## Tags

 * [templates](https://wordpress.org/support/topic-tag/templates/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [webtent](https://wordpress.org/support/users/webtent/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/problem-with-multiple-shortcode-in-page-template/#post-6888305)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
