Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Matt Campbell](https://uploads.teamtreehouse.com/production/profile-photos/86019/micro_14908333_567364846789328_4118168172751511528_n.jpg)
Matt Campbell
9,767 PointsWordpress shortcode isn't working. Building a theme. Anyone help?
I'm building a theme and a site for Wordpress. Going great-ish, making things do what I want. Learning a lot...all the usual.
I've come a cropper though and am now well and truly stuck. I'm trying to use the wordpress user front end plugin so users can upload posts etc.
However, in the installation files it says make a page and paste in this code [wpuf_addpost post_type="event"], as an example. There's plenty more like it.
In my theme it doesn't do anything, in the 2012 theme it works just fine.
I'm clearly missing something from somewhere that turns on these plugins.
I was using another plugin earlier that has dwindling support and images don't upload properly. That gave me the shortcode as above and also a line of PHP code that I pasted into the template for the relevant page. That worked just fine.
So, what am I missing and don't know to make plugin shortcodes work? Zac Gordon ?
Thanks.
9 Answers
![Matt Campbell](https://uploads.teamtreehouse.com/production/profile-photos/86019/micro_14908333_567364846789328_4118168172751511528_n.jpg)
Matt Campbell
9,767 PointsI have made it work but sure it can't be write because I don't have to do it on the default themes.
I have written into the template file for the page I want the content to run on
<?php echo do_shortcode("[the_shortcode]"); ?>
To me, this seems completely wrong because I'm writing this into the actual template code rather then just popping it into a post or page through the admin area.
However, if it works and nobody can tell me otherwise, I'll have to run with it.
![Zac Gordon](https://secure.gravatar.com/avatar/de0a01122ca4a619004332ab04431b7b?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Zac Gordon
Treehouse Guest TeacherHey Matthew Campbell - I'm assuming you saw this post on enabling short codes over on Stack Overflow. Was it helpful?
[[ed. note]] - converted html to markdown so the forum properly formatted the link
![Sergey Suhanovs](https://secure.gravatar.com/avatar/a8650f1d963e573e06be26bb513fc31d?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Sergey Suhanovs
2,077 PointsThank you for this post... spent almost 2 hours of figuring why client's wordpress site doesn't process my shortcodes from the content of the page... turns out template was displaying content using get_the_content(); which didn't process shortcodes. Changing it to apply_filters('the_content',$wp_query->post->post_content); instantly fixed the issue. THANKS!
![Matt Campbell](https://uploads.teamtreehouse.com/production/profile-photos/86019/micro_14908333_567364846789328_4118168172751511528_n.jpg)
Matt Campbell
9,767 PointsHey Zac Gordon , I hadn't seen that no but still leaves me wandering on if there is a global function that could go in functions.php that enables shortcodes in posts contents across the site? I don't know a whole lot about filters at the moment, don't remember them being covered in your videos, which are awesome by the way!
From that post you linked, I seem to kind of be doing that already by putting the shortcode in the template files where I want the relevant content. Eg. forms for front end posting etc.
Only issue is that what if the user once the site is handed over wants to the change the plugin that's being used. I know this shouldn't be the case because they shouldn't be fiddling with the theme but if they did want to.
Also, there's going to be a load of widowed code if the plugin is deactivated.
Still lots of questions for me.
![Matt Campbell](https://uploads.teamtreehouse.com/production/profile-photos/86019/micro_14908333_567364846789328_4118168172751511528_n.jpg)
Matt Campbell
9,767 PointsZac Gordon again. I'm not thinking like a WordPresser should am I? I should run a loop on ALL pages and the post should be the shortcode that links to the relevant plugin.
![Matt Campbell](https://uploads.teamtreehouse.com/production/profile-photos/86019/micro_14908333_567364846789328_4118168172751511528_n.jpg)
Matt Campbell
9,767 PointsSo would this written on each template where I want shortcodes to work be good practice?
<?php the_post(); ?>
<?php the_content(); ?>
![Zac Gordon](https://secure.gravatar.com/avatar/de0a01122ca4a619004332ab04431b7b?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Zac Gordon
Treehouse Guest TeacherYou would run the loop on all pages and add the short code to the pages from the admin area where you want them. Make sense?
![Matt Campbell](https://uploads.teamtreehouse.com/production/profile-photos/86019/micro_14908333_567364846789328_4118168172751511528_n.jpg)
Matt Campbell
9,767 PointsHey Zac Gordon. I think I got it now for main content shortcodes. Run a loop on the page I want to use shortcodes calling the_content and then the shortcodes work.
Issue I've come across you might be able to help me with is:
Got a widget from a plugin that uses [gallery] in the sidebar. No matter what, I can't get it to work.
I've done the whole filters thing in functions.php, but still no joy.
Apologies for writing like a rookie and being too technical with my terminology but it's late here in the UK.
![Zac Gordon](https://secure.gravatar.com/avatar/de0a01122ca4a619004332ab04431b7b?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Zac Gordon
Treehouse Guest TeacherHi Matthew,
What is the plugin you're referring to? How are you trying to implement it in the sidebar? By using a text widget and adding in the shortcode?
![Matt Campbell](https://uploads.teamtreehouse.com/production/profile-photos/86019/micro_14908333_567364846789328_4118168172751511528_n.jpg)
Matt Campbell
9,767 PointsHi Zac.
I can't remember what it was I was having trouble with but I think I worked it out as I'm using widgets with shortcodes all over the place now.
![Zac Gordon](https://secure.gravatar.com/avatar/de0a01122ca4a619004332ab04431b7b?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Zac Gordon
Treehouse Guest TeacherOh good!