Title: [Plugin: WP Calendar] Template shortcodes?
Last modified: August 20, 2016

---

# [Plugin: WP Calendar] Template shortcodes?

 *  Resolved [nascent666](https://wordpress.org/support/users/nascent666/)
 * (@nascent666)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-calendar-template-shortcodes/)
 * I see in the instructions that you can add a calendar to a post using the post
   tag {events_calendar}. However, I was wondering if there is a way to add a calendar
   to a template page. I tried:
 * `echo do_shortcode('[events_calendar]');`
 * This didn’t work.
 * I’m looking for a way to specify a category depending on a querystring variable.
   If I pass ?market=NY, I want to be able to display a calendar with only NY events
   in it. Ideally, it would work be doing the shortcode, as in:
 * `echo do_shortcode('[events_calendar categories="11"]');`
 * [http://wordpress.org/extend/plugins/wp-calendar/](http://wordpress.org/extend/plugins/wp-calendar/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [nascent666](https://wordpress.org/support/users/nascent666/)
 * (@nascent666)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-calendar-template-shortcodes/#post-2655589)
 * I figured it out myself, but I didn’t add the attributes to the shortcode itself:
 *     ```
       <?php
       function get_cat_info(){
       	$market = getmarket();  //function that reads querystring
       	$catname = $market."-events";
       	$idObj = get_category_by_slug($catname);
       	$id = $idObj->term_id;
       	return $id;
       };
   
       function events_calendar_func( $atts ){
       	$id = get_cat_info();
       	global $fsCalendar;
       	$content = "{events_calendar; categories=\"$id\";}";
       	return $fsCalendar->hookFilterContent($content);
       };
       add_shortcode( 'events_calendar', 'events_calendar_func' );
       ?>
       ```
   
 * Now I can put this in the template page:
 * `<?php echo do_shortcode('[events_calendar]'); ?>`

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: WP Calendar] Template shortcodes?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-calendar.svg)
 * [WP Calendar](https://wordpress.org/plugins/wp-calendar/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-calendar/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-calendar/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-calendar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-calendar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-calendar/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [nascent666](https://wordpress.org/support/users/nascent666/)
 * Last activity: [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-calendar-template-shortcodes/#post-2655589)
 * Status: resolved