Title: add_shortcode not working &#8230;
Last modified: February 15, 2017

---

# add_shortcode not working …

 *  Resolved [bdew](https://wordpress.org/support/users/bdew/)
 * (@bdew)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/add_shortcode-not-working/)
 * In my twentyseventeen-child I have functions.php. This contains:
 *     ```
       <?php
       function shortcode_hdid() {
       	return 'Hello world';
       }
       function add_ggc_shortcodes() {
           add_shortcode('hdid','shortcode_hdid');
       }
       add_action('init', 'add_ggc_shortcodes', 99); 
       ?>
       ```
   
 * … and in a page I insert [hdid] but Hello world does not appear when viewing 
   the page.
 * This is driving me mad and any help would be most appreciated.
    -  This topic was modified 9 years, 3 months ago by [bdew](https://wordpress.org/support/users/bdew/).
    -  This topic was modified 9 years, 3 months ago by [bdew](https://wordpress.org/support/users/bdew/).

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

 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/add_shortcode-not-working/#post-8810122)
 * You don’t need to use the ‘init’ action. Just call `add_shortcode()` directly.
   That makes me think that maybe calling it using the ‘init’ action is too late(
   which doesn’t seem right but is the only thing that’s wrong with the code really).
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/add_shortcode-not-working/#post-8810888)
 * It shouldn’t be too late no matter when it’s added as long as it’s before the“
   the_content” filter fires. I tried you sample code in my own installation and
   it works as expected. Apparently there is a name collision of some sort or other
   conflict. If you reduce your installation to no plugins and the twentysixteen
   theme, your code copied into twentysixteen’s functions.php should work, init 
   hook or not.
 *  Thread Starter [bdew](https://wordpress.org/support/users/bdew/)
 * (@bdew)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/add_shortcode-not-working/#post-8811287)
 * Thank you both for your prompt replies and I tried both suggestions. Initially
   without success.
 * In desperation, I started a brand new page with just [hdid] and it worked! Worked
   with or without ‘init’ with or without that name [hdid].
 * So the problem is with that particular page. So I tried a ‘trusted’ shortcode
   and that failed too. This issue I can workaround or ignore!
 * Thank you both again, topic resolved.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/add_shortcode-not-working/#post-8813954)
 * I’m glad you found a workaround. Great inspiration to try a new page! I’m guessing
   this initial page uses a special template besides the usual default page.php 
   and outputs content through some other process than calling the_content().
 * The shortcode processing script is hooked into “the_content” filter, so output
   by other means bypasses this filter and thus shortcodes are not processed. If
   one absolutely needed shortcodes to work with this template, it would need modification
   to ensure content is passed through do_shortcode() before it is output.
 *  Thread Starter [bdew](https://wordpress.org/support/users/bdew/)
 * (@bdew)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/add_shortcode-not-working/#post-8814692)
 * Nothing special about the page where shortcodes fail. Default page template –
   completely “bog standard” (if you’re British you’ll understand this expression,
   otherwise I leave you to guess!)
 * It was a test page where I had been experimenting with codes like & 1004 ; (ie&
   1004;) and I discovered that Visual mode messed these up, so there was some to-
   ing and fro-ing between Visual and Text mode. I can only assume Visual mode left
   something bad and invisible on the page. I don’t trust Visual mode and I never
   use it.
 * I copy/pasted the text from the bad page to the new page and everything worked
   ok and I deleted the bad page. (If you want me to email it to you you’ll have
   to tell me where I can find the trash and how do I grab it.).
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/add_shortcode-not-working/#post-8814985)
 * Heh, let’s leave it and let it be a mystery 🙂

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

The topic ‘add_shortcode not working …’ is closed to new replies.

## Tags

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

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 6 replies
 * 3 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/add_shortcode-not-working/#post-8814985)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
