- Simplified Chinese
- Traditional Chinese
Sometimes when creating a site, the same information needs to appear in multiple places, duplicating that content is not a good idea. It’s far better to have it in one place. That’s what the Snippets WordPress Plugin allows you to do
How Does it Work?
Follow these easy steps to use the Snuippet Plugin.
Step 1: Create your document in Google DocsOnce Snippets is installed you’ll be able to Snippets.
Step 2: Adding a new Snippet is as easy as adding normal Posts and Pages
Step 3: Using the snippet button from the editor, you can include snippets on other pages and posts.
Step 4: Select the Snippet to include (and turn off adding paragraphs automatically if you wish)
Step 5: Now the shortcode has been added to the page, you can publish!
Step 6: The Snippet has now been included in this page! You can include the same snippet anyway on the site!
In the WordPress Dashboard you will now see a new option for Snippets, this is where you can add text and copy to be re-used in other post, pages and widgets.
There are two ways you can include the snippet in your content
1) Title Method
2) ID Method
Let’s say that you create a snippet with the title CallToAction. You can include this in your posts using the following shortcode
Or if you want to insert the snippet by using the id, you could use the following format
Where 123 is the post id of the snippet. To find the post id of the snippet, look at that the address bar when editing the snippet. You will see the following:
Here 123 is the post id.
autop Parameters (defaults to yes)
By Default snippets will automatically add Paragraph tags to your snippets. You can turn this feature off by specifying autop=”no” in the shortcode
[snippet CallToAction autop="No"]
Ideas For Usage
- Call To Actions
- Address & Contact Information
- Site Announcements
- Product Details
- Post Signature
- Order Forms
Q) Can I Include shortcodes in my snippet?
A) Yes you can.
Q) Is the shortcode case sensitive?
A) Yes, CallToAction, for example, is not the same as calltoaction.
Q) Can I use a snippet in my theme?
A) Yes you can, Please look at the Snippet Theme Function
Q) What happens if I change the title of my snippet?
A) If you change the title of your snippet, and you have included it in posts, pages or widgets using the title method, then you will have to edit those posts, pages or widgets and update them, If you used the id method to include the snippet, then you do not need to make any changes.
Q) Can I have spaces in my snippet names?
A) Yes you can – however you must use the following shortcode syntax : [snippet name=”Call To Action”]
Snippet Theme Function
The plugin contains a theme function get_snippet() that can be used in your template to insert a snippet.
/* Getting a snippet by name */ $attr = array("name" =>; "CallToAction"); print get_snippet($attr);
/* Getting a snippet by ID */ $attr = array("id" => 123); print get_snippet($attr);
Sources and Credits
No external PHP related assets or copyrighted materials were used in this script’s code
- Improved code
- Add Visual Editor Button
- Added Icon
2012-09-12 – v1.1
- Minor Bug Fixes
2012-08-19 – v1.0
- Initial Release
21 August 12
17 May 14
WordPress 4.2, WordPress 4.1, WordPress 4.0, WordPress 3.9, WordPress 3.8, WordPress 3.7, WordPress 3.6, WordPress 3.5, WordPress 3.4, WordPress 3.3, WordPress 3.2, WordPress 3.1, WordPress 3.0