Title: shortcode fails to fire
Last modified: August 21, 2016

---

# shortcode fails to fire

 *  Resolved [erikstainsby](https://wordpress.org/support/users/erikstainsby/)
 * (@erikstainsby)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/shortcode-fails-to-fire/)
 * Driving me insane this is.
 * I am working in a class file structure. I set the shortcode after the class is
   instantiated, at the bottom of the class file:
 *     ```
       if( ! isset($rsconf)) {
       	global $rsconf;
       	$rsconf = new RSConference();
       	add_shortcode('rsconf_schedule', array('RSConference', 'rsconf_schedule_shortcode'));
       }
       ```
   
 * I have a trivial shortcode handler:
 *     ```
       public function rsconf_schedule_shortcode( $attrs ) {
       		error_log( __CLASS__.'::'.__FUNCTION__ );
       		return '<h2>Here</h2>';
       	}
       ```
   
 * I get no errors and I see only the literal shortcode tag:
 *     ```
       [rsconf_schedule]
       ```
   
 * This is making me mental. Anyone?

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

 *  [Chris](https://wordpress.org/support/users/zenation/)
 * (@zenation)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/shortcode-fails-to-fire/#post-4297396)
 * Three ideas:
 * 1. The way you’re referencing the method to handle the shortcode it needs to 
   be “static”
 *     ```
       public static function rsconf_schedule_shortcode( $attrs ) {
   
         error_log( __CLASS__ . '::' . __FUNCTION__ );
   
       	return '<h2>Here</h2>';
   
       }
       ```
   
 * 2. Or if the add_shortcode part and the function rsconf_schedule_shortcode are
   defined within the same class you could make an internal reference.
 * `add_shortcode( 'rsconf_schedule', array( $this, 'rsconf_schedule_shortcode' ));`
 * Then the method wouldn’t have to be static.
 * 3. Are you sure the first code block even runs? If not, why not add the “add_shortcode(…)”
   to the constructor?
 *  [Chris](https://wordpress.org/support/users/zenation/)
 * (@zenation)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/shortcode-fails-to-fire/#post-4297420)
 * A 4th idea would be to pass the object instead of the class (name) like
 * `add_shortcode( 'rsconf_schedule', array( $rsconf, 'rsconf_schedule_shortcode'));`
 *  Thread Starter [erikstainsby](https://wordpress.org/support/users/erikstainsby/)
 * (@erikstainsby)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/shortcode-fails-to-fire/#post-4297430)
 * Thanks for the input Chris. Alas, these sugggestions seem not to have the desired
   effect.
 * I have discovered that there seems to be an issue using shortcodes with multisite
   with subdirectoriies(?) I am able to get a shortcode to render if it is in a 
   plugin activated on the base blog (blog 1). It seems that shortcodes will not
   work from subdirectory-activated plugins. This is really puzzling. I can’t imagine
   this is true for everyone. There would be a mass developer outcry against such
   restrictions.
 * Here is a restatement of my code in case something jumps out at someone.
 *     ```
       if( ! class_exists('RSConferenceDisplay')) : 
   
       include_once( ABSPATH.'wp-includes/pluggable.php');
       include_once( ABSPATH.'wp-includes/shortcodes.php');
   
       class RSConferenceDisplay {
       	function __construct() {
       		add_action( 'init', array( &$this, '_init' ) );
   
       		add_shortcode('rsconf_regform',array( &$this, 'rsconf_registration_form' ));
       	}
   
       	function _init() {
       		error_log( __CLASS__.'::'.__FUNCTION__ );
       	}
   
       	public function rsconf_registration_form() {
       		error_log( __CLASS__.'::'.__FUNCTION__ );
       		$out = array( '<div class="rsc_registration">');
       		$out[] = '<h1>Shortcode</h1>';
       		$out[] = '</div><!-- .rsc_registration -->';
       		return implode("\n",$out);
       	}
       }
   
       if( ! isset( $rsdisplay )) {
       	global $rsdisplay;
       	$rsdisplay = new RSConferenceDisplay();
       }
       endif;
       ```
   
 * I see the _init method firing when the plugin loads, but the shortcode does not
   get replaced in the page which calls it.
 *  Thread Starter [erikstainsby](https://wordpress.org/support/users/erikstainsby/)
 * (@erikstainsby)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/shortcode-fails-to-fire/#post-4297434)
 * Solved it. The theme file was calling `get_the_content()` instead of using `the_content()`.
 * See also this WordPress Answers article: [http://wordpress.stackexchange.com/questions/22482/loop-on-page-makes-shortcode-fail](http://wordpress.stackexchange.com/questions/22482/loop-on-page-makes-shortcode-fail)

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

The topic ‘shortcode fails to fire’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 4 replies
 * 2 participants
 * Last reply from: [erikstainsby](https://wordpress.org/support/users/erikstainsby/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/shortcode-fails-to-fire/#post-4297434)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
