最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to define WordPress plugin shortcode globally for multisite?

programmeradmin1浏览0评论

I have a multisite project in which I have WordPress networked multi site.

In my site I have many of the plugins like photo gallery, video gallery, and widget.

I have created shortcode and I use them in the first site. But in other site it is not working. So I wanted to know the solution. How I can use the same shortcode for all the website?

My all website theme is same.

I have a multisite project in which I have WordPress networked multi site.

In my site I have many of the plugins like photo gallery, video gallery, and widget.

I have created shortcode and I use them in the first site. But in other site it is not working. So I wanted to know the solution. How I can use the same shortcode for all the website?

My all website theme is same.

Share Improve this question edited May 17, 2017 at 0:14 Nathan Johnson 6,5286 gold badges30 silver badges49 bronze badges asked May 16, 2017 at 21:32 FAISAL KHANFAISAL KHAN 112 bronze badges 2
  • 2 You have to enable a plugin on all sites to use it on all sites – Tom J Nowell Commented May 16, 2017 at 21:43
  • @Tom is correct. The plugin must be enabled on all sub-sites or it won't work on that sub-site. (Been there, done that, spent several days before the "Doh!' moment.) – Rick Hellewell Commented May 17, 2017 at 20:34
Add a comment  | 

1 Answer 1

Reset to default 2

I suggest you to create a Network-only plugin that is Active for all the sites in the network and define your shortcodes inside.

To make specific plugin Network-only you need to add Network: True to your plugin definition, just like the example below.

Change:

/*
Plugin Name: My Awesome Plugin
Plugin URI: http://yourplugin/
Description: This is my extremely awesome WordPress plugin
Version: 1.0
Author: John Doe
Author URI: http://yourcompany
License: GPLv2
*/

to the following:

/*
Plugin Name: My Awesome Plugin
Plugin URI: http://yourplugin/
Description: This is my extremely awesome WordPress plugin
Version: 1.0
Author: John Doe
Author URI: http://yourcompany
License: GPLv2
Network: True
*/

After this is done make sure you activate your plugin from the Network Admin and the shortcodes defined in your plugin should work on all the sites in the network.

发布评论

评论列表(0)

  1. 暂无评论