Add_shortcode not working in WordPress – How to Fix

Add shortcode in WordPress not working so you need to take 2 step or may be 3 step. Checkout how to tackle shortcode problem in WordPress.

Shortcode is a tremendous achievement of WordPress to solve hundred of problems. The Add_shortcode not working and broken content may appears. while developing a plugin or displaying content using shortcode (e.g Custom post type with Shortcode). Explore add_shortcode not working or crash below some huge findings to solve your wp short code problem.

Fix Add_Shortcode not Working – WordPress

Shortcode problem can be solved via override approach or by registering at init level. Possible problems would be,

  • Shortcode may already exists in a theme.
  • Register shortcode at init level.
  • Overrides previously registered short code.

Use “Remove_Shortcode” Approach:

Theme developer already register the code, remove it by remove_shortcode.



Try Adding Shortcode at Init Level:

use add_action with init to add the code.

function abc(){


Final Fix: Override all behavior of Shortcode:

May your shortcode exists already by the grace of core functionalities (e.g. gallery). You may try the following fix we are taking the example of Gallery shortcode.

  1. Remove the shortcode first.
  2. Enclose our code in a function.
  3. Use “add_action” to init the function at “init” level.
  4. Add a priority to load in the last. It may be any number e.g 9999

Example of Code:

 remove_shortcode('gallery', 'gallery_shortcode');
 add_action('init', 'add_my_gallery_shortcode', 99);
 function add_my_gallery_shortcode() {
      add_shortcode( 'gallery', 'my_gallery_shortcode');
 function my_gallery_shortcode( $attr ) {
     // the new gallery logic here

The number 99 is the priority for action to execute.  Higher priority executes in the end and overlap previous functionalities. Setting priority makes more possibility to overcome shortcode failure.

Add Shortcode & Add Action:

Leave a Reply

Your email address will not be published. Required fields are marked *