Title: Shortcode in Template
Last modified: August 22, 2016

---

# Shortcode in Template

 *  Resolved [Back to Front](https://wordpress.org/support/users/traverser11/)
 * (@traverser11)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/shortcode-in-template-6/)
 * Hi thanks for the sweet plugin – I love that it does exactly and only what I 
   want.
 * However I’m having some trouble getting the shortcode working in a template…
 * I’m trying to do is get this tweet to appear if URL is ?success.
 *     ```
       <?php if (isset($_GET['success'])) {
        echo do_shortcode('[tweetthis]'.'Woohoo! Success'.'[/tweetthis]');
       }
       ?>
       ```
   
 * This generates all the TT divs when ?success- but without the text in the middle!
 * Tried a bunch of different syntax, instead of including ‘,’ & ”
 * But so far, I fail. Any suggestions?
 * [https://wordpress.org/plugins/tweetthis/](https://wordpress.org/plugins/tweetthis/)

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

 *  Thread Starter [Back to Front](https://wordpress.org/support/users/traverser11/)
 * (@traverser11)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/shortcode-in-template-6/#post-5387279)
 * Oh, maybe this is actually a css issue?
 * here is a test page [http://www.whatsbehindjnf.org/penguin/?success=1&post_id=321](http://www.whatsbehindjnf.org/penguin/?success=1&post_id=321)
 *  Plugin Author [John Morris](https://wordpress.org/support/users/jtmorris/)
 * (@jtmorris)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/shortcode-in-template-6/#post-5387479)
 * Hi traverser11,
 * Sorry for the response delay. I received a flurry of messages in a short period
   of time for this and my other plugin, and have been scrambling to catch up.
 * I just tried the exact code in your first post in the default Twenty Fourteen
   theme, and it works as expected on my end. I also downloaded the theme I think
   yours is, or is based on, (called “Spun” I believe), and it also worked.
 * _Screenshots:
    Editor: [http://1drv.ms/ZydBC3](http://1drv.ms/ZydBC3) Result:
   [http://1drv.ms/1wjDRx5](http://1drv.ms/1wjDRx5)
 * Is it possible for you check if this happens using a different theme? Also try
   it with any CSS overrides you may have specified temporarily removed?
 * If it does not happen on another theme (like Twenty Fourteen), and with no CSS
   overrides, then this is likely a compatibility issues with the theme you’re using,
   and that probably means CSS like you said.
 * With this information, I can narrow down whether I need to look for a plugin 
   functionality problem, or a plugin compatibility problem.
 * ——————-
 * Also, on the test page you sent, I don’t see any of the TT divs on the page or
   in the source code at all… with ?success=1 in the URL or without. Did the test
   page change? If it did change, can you create another test page. If it didn’t,
   can you verify again that the page does what you’re describing.
 * ——————-
 * Thanks, and I hope we get this worked out!
 *  Thread Starter [Back to Front](https://wordpress.org/support/users/traverser11/)
 * (@traverser11)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/shortcode-in-template-6/#post-5387482)
 * Hi John, thanks so much and sorry for the trouble!
    After much bewilderment yesterday
   I finally figured out, The embarressing issue was – Ad Block!
 * Not being confident with my coding ability I just assumed something was wrong.
 * 
 * Thanks for the thorough investigation so sorry for the bother when everythings
   actually working as it should!
 *  Thread Starter [Back to Front](https://wordpress.org/support/users/traverser11/)
 * (@traverser11)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/shortcode-in-template-6/#post-5387483)
 * lol i mean inside the a tags
 *  Plugin Author [John Morris](https://wordpress.org/support/users/jtmorris/)
 * (@jtmorris)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/shortcode-in-template-6/#post-5387500)
 * Ah. Those pesky ad blockers. I’m very familiar with them and the problems they
   can cause because I have [another plugin that detects them](https://wordpress.org/plugins/ad-blocking-detector/).
 * I can’t think of a way to make the whole ad block automatic stripping work all
   the time. Ad blockers don’t announce when they’ve removed something. But I do
   have two suggestions that would work almost every time. I don’t want to make 
   them part of the plugin because it’s beyond the scope of it, but you might be
   able to take advantage of them on your own.
 * The suggestions are similar, but I think the first is better for your case.
 * 1.) Use JavaScript to look to see if the <div>s are empty, and if so, hide them.
   You can put the following JavaScript in your theme somewhere, and I believe it
   will hide boxes emptied by that ad blocker.
 *     ```
       jQuery("div.TT_wrapper").each(function() {
          var hidett = false;
          if(jQuery.trim(jQuery(this).text()) == "") {
             hidett = true;
          }
          if(jQuery.trim(jQuery("div.TT_text", this).text()) == "") {
             hidett = true;
          }
   
          if(hidett) {
             jQuery(this).remove();
          }
       });
       ```
   
 * I haven’t tested this personally, but from what you described, I think it will
   work.
 * ———————–
 * 2.) Use my ad block detection plugin I mentioned and tie it in with Tweet This.
   It will be easier to understand what I am about to say if you look at it first.
   It’s called [Ad Blocking Detector](https://wordpress.org/plugins/ad-blocking-detector/).
 * Copy and paste the Tweet This shortcode that is being blocked into a new Ad Blocking
   Detector shortcode’s “No Ad Blocker Detected” field, give the new shortcode a
   name, and leave all the other fields blank. Then save the shortcode. Now, in 
   your theme where you are trying to put this Tweet This shortcode, put the Ad 
   Blocking Detector shortcode instead. When it doesn’t find any ad blockers, the
   Tweet This shortcode will display. When it does find ad blockers, nothing will
   display.
 * I don’t think this is your best choice because not all ad blockers empty your
   Tweet This box, yet Ad Blocking Detector will hide it every time it finds an 
   ad blocker. The first suggestion only hides it when it’s empty.
 * ——————–
 * Neither suggestion is completely reliable. They both depend on your site’s visitors
   having JavaScript turned on (which will be the vast, vast majority) and the ad
   blocker working a certain way. But if you’re set on using blockable content in
   the Tweet This box, these will work for most people.

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

The topic ‘Shortcode in Template’ is closed to new replies.

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

## Tags

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

 * 5 replies
 * 2 participants
 * Last reply from: [John Morris](https://wordpress.org/support/users/jtmorris/)
 * Last activity: [11 years, 10 months ago](https://wordpress.org/support/topic/shortcode-in-template-6/#post-5387500)
 * Status: resolved