Title: Plugin Shortcode in wordpress 4.5 not Working
Last modified: August 31, 2016

---

# Plugin Shortcode in wordpress 4.5 not Working

 *  [leapyear16](https://wordpress.org/support/users/leapyear16/)
 * (@leapyear16)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/plugin-shortcode-in-wordpress-45-not-working/)
 * Hello.
 * This should be very simple but for me, I am learning wordpress for the first 
   time although I am good in PHP.
 * I would have a php code which I wish to have as a plugin. However, when I paste
   the shortcode in a post, the shortcode does not work.
 * Here is a simple plugin I am working with as a dummy.
 *     ```
       <?php
       defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
       /*
       Plugin Name: My Leap Year
       */
       function test() {
       echo'Is the shortcode working?';
       }
       add_shortcode( 'leap', 'test' );
       ```
   
 * The shortcode [leap] does not work when I paste it in a post/page. How can I 
   make it work?

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

 *  [omii](https://wordpress.org/support/users/omii/)
 * (@omii)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/plugin-shortcode-in-wordpress-45-not-working/#post-7321316)
 * Try this:
 *     ```
       function example_shortcode() {
          return 'Is this shortcode working?'; // return the content
       }
       add_shortcode( 'examplesc', 'example_shortcode' );
       ```
   
 * Simple difference is returning the string. Just place in [examplesc] in any post/
   page.
 * I use a ton of custom shortcodes and I updated to 4.5. It’s working just fine.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/plugin-shortcode-in-wordpress-45-not-working/#post-7321368)
 * there is information about creating shortcodes in the Codex [https://codex.wordpress.org/Shortcode_API](https://codex.wordpress.org/Shortcode_API)
 *  Thread Starter [leapyear16](https://wordpress.org/support/users/leapyear16/)
 * (@leapyear16)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/plugin-shortcode-in-wordpress-45-not-working/#post-7321484)
 *  Thread Starter [leapyear16](https://wordpress.org/support/users/leapyear16/)
 * (@leapyear16)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/plugin-shortcode-in-wordpress-45-not-working/#post-7321485)
 * I finally got it working by using this code;
 *     ```
       <?php
       defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
       /*
       Plugin Name: 1245378
       Description: This plugin was created to do bla bla bla...
       Version: 1.0
       */
       function test_me() {
       require_once('mr_happy.php'); //This is a script that executes some other tasks.
       }
       add_shortcode( 'leap', 'test_me' );
       ```
   

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

The topic ‘Plugin Shortcode in wordpress 4.5 not Working’ is closed to new replies.

## Tags

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

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 4 replies
 * 3 participants
 * Last reply from: [leapyear16](https://wordpress.org/support/users/leapyear16/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/plugin-shortcode-in-wordpress-45-not-working/#post-7321485)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
