Title: Global Shortcodes
Last modified: August 19, 2016

---

# Global Shortcodes

 *  [dalmatian](https://wordpress.org/support/users/dalmatian/)
 * (@dalmatian)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/global-shortcodes-1/)
 * I found a post from a few weeks ago about using custom shortcodes globally across
   all your multisite blogs. I was just after a bit more information.
 * I’ve installed a plugin called Shortcoder, and network activated it, but shortcodes
   i create under super admin arent able to be used by subdomain blogs.
 * Can someone give me some pointers about how to create shortcodes that i can then
   use across any of my blogs. I’m after adding some static content to all my sites,
   which i can edit centrally, and this may well be the best way to do it.
 * Thanks

Viewing 1 replies (of 1 total)

 *  [David Sader](https://wordpress.org/support/users/dsader/)
 * (@dsader)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/global-shortcodes-1/#post-1781555)
 * First,
 * > how to create shortcodes
 * Reading: [http://codex.wordpress.org/Shortcode_API](http://codex.wordpress.org/Shortcode_API)
 * Multisite tip: Stick the following in your “mu-plugins” folder
 *     ```
       // [bartag foo="foo-value"]
       function bartag_func($atts) {
       	extract(shortcode_atts(array(
       		'foo' => 'something',
       		'bar' => 'something else',
       	), $atts));
   
       	return "foo = {$foo}";
       }
       add_shortcode('bartag', 'bartag_func');
       ```
   
 * Then
    `[bartag foo="something" bar="something else"]` in any post from any site.
 * Second,
 * > I’ve installed a plugin called Shortcoder, and network activated it, but shortcodes
   > i create under super admin arent able to be used by subdomain blogs
 * Shortcoder is going to save its array of options as blog options. Looking briefly
   at the Shortcoder code, it is possible to hook the option_pre filter and have
   the plugin retrieve options from another blog(or hard code the option array)
 * Examples:
    [http://wordpress.org/support/topic/possible-to-set-default-plugin-settings-for-every-blog](http://wordpress.org/support/topic/possible-to-set-default-plugin-settings-for-every-blog)
   [http://wordpress.org/support/topic/sub-blogs-use-the-main-blog-widgets](http://wordpress.org/support/topic/sub-blogs-use-the-main-blog-widgets)
 * FInally:
    So, (net)activate and maintain Shortcoder in the usual way but put 
   something like this in your “mu-plugins” and the options will come from what 
   is saved on blog 1, no matter which blog uses the shortcode/plugin. (Also remove
   the Shortcoder menu from every blog but the main.)
 *     ```
       <?php
       global $blog_id;
       if($blog_id != '1') {
       	add_filter( 'pre_option_' . 'shortcoder_data', 'override_shortcoder_data' );
       	add_action( 'plugins_loaded', 'override_sc_addpage');
   
       function override_sc_addpage() {
       	remove_action( 'admin_menu', 'sc_addpage');
       }
       function override_shortcoder_data() {
       	$bar = get_blog_option('1','shortcoder_data');
       	return $bar;
       }
       }
       ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Global Shortcodes’ is closed to new replies.

## Tags

 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [global](https://wordpress.org/support/topic-tag/global/)
 * [multisite](https://wordpress.org/support/topic-tag/multisite/)

 * In: [Networking WordPress](https://wordpress.org/support/forum/multisite/)
 * 1 reply
 * 2 participants
 * Last reply from: [David Sader](https://wordpress.org/support/users/dsader/)
 * Last activity: [15 years, 7 months ago](https://wordpress.org/support/topic/global-shortcodes-1/#post-1781555)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
