Title: Using shortcodes in template files
Last modified: August 22, 2016

---

# Using shortcodes in template files

 *  Resolved [Olaf Lederer](https://wordpress.org/support/users/finalwebsites/)
 * (@finalwebsites)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/using-shortcodes-in-template-files/)
 * Hi,
 * I’m trying to use the shortcodes right in my theme files like
 * `echo do_shortcode('[shiftcontroller]');`
 * But it doesn’t output anything, any idea why this happens?
 * [https://wordpress.org/plugins/shiftcontroller/](https://wordpress.org/plugins/shiftcontroller/)

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

 *  [hitcode](https://wordpress.org/support/users/hitcode/)
 * (@hitcode)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/using-shortcodes-in-template-files/#post-5693119)
 * Hi Olaf,
    sorry at the moment the do_shortcode() will not work with our plugin
   because it should do some stuff during wp init, i.e. enqueue scripts and styles,
   process cookies etc, while to my knowledge the do_shortcode() function comes 
   just too late for this.
 *  Thread Starter [Olaf Lederer](https://wordpress.org/support/users/finalwebsites/)
 * (@finalwebsites)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/using-shortcodes-in-template-files/#post-5693149)
 * Hi,
 * right your port from shiftexec to WordPress is not like most other WP plugins
   🙂
 * I tried a custom shortcode because I need a page that shows only the shifts from
   a single user (using a dynamic user ID). I solved it by creating a short code
   with a dynamic link using your link structure:
 * [http://domain.com/mypage/?/wall/index/staff/3](http://domain.com/mypage/?/wall/index/staff/3)
 * Do you have plans for localization? Would be cool to have the plugin in Dutch
   language too.
 *  [hitcode](https://wordpress.org/support/users/hitcode/)
 * (@hitcode)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/using-shortcodes-in-template-files/#post-5693181)
 * Hello Olaf,
    by the way, did you want to display the shifts of the currently 
   logged in user? If yes, then we have an undocumented 🙂 feature: you can supply
   the ‘_current_user_id_’ for the ‘staff’ shortcode parameter and it will translate
   it to the current user:
 *     ```
       [shiftcontroller staff="_current_user_id_"]
       ```
   
 * Regarding localization, internally it’s already there but it it’s not in the 
   WP way, you will need to translate a language file: create a new subfolder for
   your language here:
    shiftcontroller/application/language then copy the app_lang.
   php language file from the English subfolder, then translate it. Then you will
   need to edit this file: shiftcontroller/happ/application/config/config.php on
   line 137 change the language: `$config['language'] = 'dutch';`
 * Please note that this changes will be overwritten by automatic updates so it’ll
   be required to keep a backup somehow. We also plan to add localization options
   that can be manages through the admin control panel.
 *  Thread Starter [Olaf Lederer](https://wordpress.org/support/users/finalwebsites/)
 * (@finalwebsites)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/using-shortcodes-in-template-files/#post-5693189)
 * > by the way, did you want to display the shifts of the currently logged in user?
   > If yes, then we have an undocumented 🙂 feature:
 * Nice, but a bit too late 🙁
 * Thanks for this information regarding the translations.
 *  [aaron2310](https://wordpress.org/support/users/aaron2310/)
 * (@aaron2310)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/using-shortcodes-in-template-files/#post-5693211)
 * I’m having the same issue with my theme. Unfortunately shortcodes don’t work 
   in it (and I can’t figure out why despite reading many pages on the issue) so
   I rely on do_shortcode.
 * Would you fix work for me, Olaf? And how did you get it to display?
 * Thanks 🙂
 *  Thread Starter [Olaf Lederer](https://wordpress.org/support/users/finalwebsites/)
 * (@finalwebsites)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/using-shortcodes-in-template-files/#post-5693212)
 * Hi Aaron, do you tried the shortcode suggested by the plugin author?
 *  [aaron2310](https://wordpress.org/support/users/aaron2310/)
 * (@aaron2310)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/using-shortcodes-in-template-files/#post-5693213)
 * Hi Olaf,
 * I’ve tried it. It just returns the shortcode as text where I post it. I’ve built
   a custom theme that just wont support shortcodes. So I’m wondering if there was
   an alternate way to display the rota since it doesn’t support do_shortcode?
 *  [aaron2310](https://wordpress.org/support/users/aaron2310/)
 * (@aaron2310)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/using-shortcodes-in-template-files/#post-5693214)
 * Just to a little more specific, I was trying to put it into my template, not 
   a page (it works in a page). Having found out a little more I understand shortcodes
   wont work directly in the template and do need the do_shortcode to work for that.
 * Is there any workaround for this?
 *  Thread Starter [Olaf Lederer](https://wordpress.org/support/users/finalwebsites/)
 * (@finalwebsites)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/using-shortcodes-in-template-files/#post-5693215)
 * Hi,
 * You can’t use a shiftcontroler shortcode in your theme.
    If I add this shortcode
   to a new page, I get the shifts for the current user:
 * `[shiftcontroller staff="_current_user_id_"]`
 * I’m sure you can use other shortcode attributes too.
 *  [hitcode](https://wordpress.org/support/users/hitcode/)
 * (@hitcode)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/using-shortcodes-in-template-files/#post-5693218)
 * Hello Aaron,
    sorry at the moment the do_shortcode() will not work with our plugin
   because it should do some stuff during wp init, i.e. enqueue scripts and styles,
   process cookies etc, while to my knowledge the do_shortcode() function comes 
   just too late for this.
 *  [aaron2310](https://wordpress.org/support/users/aaron2310/)
 * (@aaron2310)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/using-shortcodes-in-template-files/#post-5693222)
 * Hi guys,
 * Thanks for the replies. I’ve realized I can’t put the output into my theme via
   Shortcode or the do_shortcode line.
 * I was experimenting with using a text widget to do it instead. So I’ve added 
   the filter to my Functions.php that allows this and then put the shortcode into
   the text widget.
 * And it displays fine on the same page that I’m already using the shortcode within
   the content. On any other page it doesn’t.
 * Is this related to the inability to do the do_shortcode?
 *  [hitcode](https://wordpress.org/support/users/hitcode/)
 * (@hitcode)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/using-shortcodes-in-template-files/#post-5693223)
 * Hello,
    yes currently our plugin will only work on the page with our shortcode–
   during the WP init we catch if the page has the shortcode, then we invoke some
   init code, enqueue scripts and styles, all this is required for the plugin to
   work, and it can be done only during WP init, the widgets and templates are coming
   too late for that.

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

The topic ‘Using shortcodes in template files’ is closed to new replies.

 * ![](https://ps.w.org/shiftcontroller/assets/icon-128x128.png?rev=1851172)
 * [ShiftController Employee Shift Scheduling](https://wordpress.org/plugins/shiftcontroller/)
 * [Support Threads](https://wordpress.org/support/plugin/shiftcontroller/)
 * [Active Topics](https://wordpress.org/support/plugin/shiftcontroller/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shiftcontroller/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shiftcontroller/reviews/)

## Tags

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

 * 12 replies
 * 3 participants
 * Last reply from: [hitcode](https://wordpress.org/support/users/hitcode/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/using-shortcodes-in-template-files/#post-5693223)
 * Status: resolved