Create Snippets! This plugin adds a new Post Type. Snippets can be included in Posts/Pages/Widgets via shortcodes.
Using a Snippet that you've created in the WP Editor. Follow this simple Shortcode syntax.
[snippet slug="my-cool-snippet" /]
Using a Snippet that you've created inside a PHP template file.
<?php echo do_shortcode('[snippet slug="my-cool-snippet" /]'); ?>
By default, only WordPress® Administrators can manage (i.e. create/edit/delete/manage) Snippets. Editors and Authors can create/edit/delete their own Snippets, but permissions are limited for Editors/Authors. If you would like to give other WordPress Roles the Capabilities required, please use a plugin like Enhanced Capability Manager.
Add the following Capabilities to the additional Roles that should be allowed to manage Snippets.
$caps = array ( 'edit_snippets', 'edit_others_snippets', 'edit_published_snippets', 'edit_private_snippets', 'publish_snippets', 'delete_snippets', 'delete_private_snippets', 'delete_published_snippets', 'delete_others_snippets', 'read_private_snippets' );
NOTE: There are also some WordPress filters integrated into the code for this plugin, which can make permissions easier to deal with in many cases. You can have a look at the source code and determine how to proceed on your own; if you choose this route.
Yes. Absolutely. You can even nest one Snippet inside another one via Shortcodes.
Yes. When creating a new Snippet, please wrap your Snippet content with
[raw][/raw] tags; or with
<!--raw--><!--/raw--> tags. Consult the Raw HTML documentation on this please. An important point to make is that Snippets are self-contained. Applying Raw HTML to a Post/Page that includes a Snippet via
[snippet slug="my-snippet" /], will NOT apply Raw HTML to the Snippet content itself. You must wrap the Snippet content with raw tags to achieve this. This actually provides a great deal of flexibility, because it allows you to have a Raw HTML Post or Page, but have Snippets that were designed in the WP Visual Editor (or vice versa — and even mixtures, if you include multiple Snippets).
Yes. Absolutely. I recommend this KB article: s2Member® Simple Conditionals. s2Member's Simple Shortcode Conditionals can be used inside a Snippet itself, or by wrapping your Snippet Shortcode when you put it into a Post or Page. Either way is fine.
Requires: 3.2 or higher
Compatible up to: 3.7.1
Last Updated: 2013-11-21
0 of 1 support threads in the last two months have been resolved.
Got something to say? Need help?