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.
The topic ‘Problem with multiple shortcode in page template’ is closed to new replies.