One of my favorite plugins has always been Widget Logic, which allows you to display/hide widgets based on context. The biggest limitation of that plugin to me is that I had to go to my Widgets screen in my WordPress admin every time I wanted to add a new widget for a single post or page.
What I wanted was something that allowed me to control widget content from the post editor, so I wouldn’t have to worry about setting my widgets. This gave me the idea for the My Snippets plugin.
What this plugin does is add an extra meta box on the post editor that allows you to input custom content. This content is then displayed using the Snippet widget in any widget area you choose.
How the plugin works
First, you’d add the Snippet widget to the widget area of your choosing. You’ll need that to display your custom snippets.
When writing a post (or page), you’ll have an extra meta box labeled Snippet Post Settings. In this box, you can add text, HTML, and shortcodes.
Here’s an example of adding a video snippet:

Here’s the output of the snippet, which will only be displayed on the singular view of the post/page I added it to:

Don’t be fooled by the example though. You can add pretty much anything in your snippet meta box, so feel free to go wild.
Download the plugin
Before using the plugin, please take a moment to read through the readme.html file included with the plugin download.
- Version: 0.1
- Requires: WordPress 2.8+
- Support: Support forums
- Download (from WP.org)
Please don’t use my contact page or the comments section below to ask support questions. Use my support forums at Theme Hybrid, which is where I handle all support questions for my WordPress projects.

Just the kind of thing I am looking for, but would be nice if it had the WYSIWYG editor on it for people that don’t know HTML.
Another great plugin of yours, congrats!
Just a quick question: can we include php code in the snippet? From your post, I’d say no, so if that’s the case do you have another plugin up your sleeves to help me do that?
Very nice. It’s a great improvement to helping novice users figure out how to update their sidebar for a particular page. For some reason they don’t quite grasp `if(is_page(‘about’))`
Kevin — I’m not much of a fan of the visual editor, but it’s something to consider for a future version.
Jeremy — Currently, PHP isn’t allowed, but I’m thinking of integrating it with something like the Exec-PHP plugin. I’m fairly certain it adds a certain capability to user roles, so I might run a check for that.
Patrick Daly — That’s exactly the use-case I had in mind. The more advanced of us can code this in about 2 seconds, but novice users should find this easier to grasp.
Excellent job! Does this also have a template tag we can use? Or is it Widget only?
It’s widget only. With a template tag, the plugin becomes rather useless. What I mean by this is that if you’re diving into your theme’s templates, then you might as well not be using the plugin. The plugin is just a wrapper (widget) for a custom field. If you’re advanced enough to want to add it via template tag, then just use custom fields.
Thanks for the recommended plugin… i like to try it
nice plugin
it works perfect
This looks to be a very useful plugin. Having the ability to control widget presentation from the post editor motivates me to provide more dynamic content in the sidebar because of the convenience factor. I’ll have to make it a point to integrate this into my site.
This is a very useful plugin especially when used on a magazine style site. I haven’t looked at it yet but one question popped into my mind: if you put the Snippets widget into more than one widget area, would it be possible to choose in the post meta box which snippet widget should display the content?
That’s a bit outside the current scope of the plugin.
Very clever. For my clients who are “editors” of a website and who cannot see the widget area… You save my life
Gonna use it right now !
I’ve never really thought about using it that way. This would come in handy for situations where specific authors could add widget content without having the ability to change things on the widgets admin screen.
the plugin looks cool. can we set a default snippet that appear in every post? or we need to customize it one by one in every post.
A default snippet would go against the purpose of the plugin. It’s meant to be used on a post-by-post basis.
Great idea. thanx for sharing the information. I will surely going to use this.
Sweet! I have been having issues with my video configuration on my blog. This should solve my problem much easier then I was trying to do it. Thanks mate!
Justin,
Thanks for sharing this plugin. Great Idea. Having a problem with the Excerpt header covering the snippit box…tried deactivating it and then reactivating it but that didn’t help. I have the latest install of WP and plugins. Could be a another plugin conflicting with it. Any suggestions?
Nice, very nice. The applications for this plugin are endless. Just what I needed
@Justin —
Again, sir, you are a genius. I have run across an application where this was the exact functionality I needed, and you have provided exactly the solution.
@Kevin –
For the time being, just use the regular visual editor to generate the code, then cut the HTML version and paste it into the Snippet box.
Well, I’m glad I could be of some assistance.
My question is the same as Robert above. Since we can now have widgets in more places than just the sidebar is it possible to have more than one snippet widget with different content in each. Ex. One Snippet in the sidebar widget, one in the Footer widget and different content in each based on the field that is populated in the post editor?
This would be as you say “Going Wild” with this plugin. BTW, fantastic plugin and it isn’t just for the newbie. Sometimes we don’t want spend time (or have time) to do it with code. This plugin greatly simplifies unique content for each post.
Thanks so much for a fantastic and useful plugin.
I’m in favor of a more simplistic approach with the plugin for now. Multiple snippets makes things immensely more complicated, but it may be something to consider down the road.
Hi Justin,
I love this plugin – a must have!
Like Robert and Dave, once I see this plugin – I wish that I could use it in multiple places. One idea is to assign an “snippet ID name” in widget admin, which will be displayed in the editing page instead of current “snippet post settings” box.
Anyway, I definitely more than happy using this plugin right now. Thanks for creating this fantastic plug-in!
I’m in the same boat as @Dave Smith and @Robert above. This Plugin is exactly what I wished I had for a previous project. And I’m now about to create a large CMS site where this would be invaluable. BUT, they have multiple content areas per page.
I dropped the widget into more than one widget area and went to the edit screen expecting to see more that one post meta box (or one with sub fields for each widget). It would be invaluable to be able to have this functionality. I would think you would do what you have now but add a container for each that has the default title as the header to help differentiate (and/or the widget area title with default title).
Any chance of this happening?
Dax
It’s not on the to-do list right now, but it is an idea I’ll consider at some point.
Hi Justin! Like Jeremy, It would certainly be great if this will support PHP. I am one of those who use Exec-PHP and it doesn’t seem to be updated that much, although it works fine on WP 2.8+ versions. (At least that’s what I see when I look at it directly from searching through the plugin search panel on my WP.) Would be great if we get options, one that is newer and freshly maintained, on this type of plugin (that execute PHP code) especially when it seems another major version of WP is coming out soon. Cheers!
I’ll look into integration with some PHP plugins. I don’t think this will be something the My Snippets plugin will offer, but integration is something to consider.
@Dave Smith, @Dax Davis, I have made some mods to the Snippets widget to allow selecting a position if the widget has been used more than once in sidebars. I have sent the code to Justin so he can review it and include it in the next plugin release if he thinks it’s OK.
I did look over the mods, but I’m not sure if I ever emailed you back about the changes.
Overall, the idea is not bad, but it’s far from the way I’d implement multiple snippets. To me, it didn’t take advantage of the current metadata API in WordPress in the best way. At the same time, the system can be more complex (development-wise) than the way you implemented your changes.
Aww, just saw your reply now.
My mod was a quick (& dirty) job to see if/how this could be done. I’m not sure if I can guess what you had in mind with taking advantage of the metadata api?
For everyone’s information, my approach is really crude
– add a position drop-down to the metabox
- to populate that, get all widgets, ignore the inactive ones, check if the snippets widget is there and grab that sidebar ID and name for the postition dropdown.
- in the widget code, check if widget is set for the associated position and display if it is.
Great plugin and concept. This plugin will definitely come in handy. Thanks!
Is there any possible way to include the wp gallery button within the snippet admin box? that way instead of having to paste in code, the user could select an image from the gallery and link that to another page, lightbox, external link etc.. Or they could select a video and have it embedded, same with audio etc..?
I was even thinking for those that use the kaltura video system, we could even have the kaltura browse/upload button there like we do in posts?
Could even link it to a shopping cart image like a book for sale that relates to the article
Man the ideas are endless….
p.s.
+1 for php_exec(with permissions), and also multi-snippets
oh…does it work with wpmu?
I’m not too big on adding fancy things to the plugin. Mostly, I want to keep it as simple as possible.
As for WPMU, I neither develop for nor test for that platform. So, all I can say is try it out.
Yes it works with WPMu. Just install it as a regular plugin.
This is a great, simple plugin. As a general newbie I wasn’t even aware that this could be done manually. And frankly, I’d much rather use this plugin than mess around with the code. As others have mentioned, this would be great to be able to use in more than one place on the page. -James
Yep, it’s extremely simple to do this manually. It’s just WordPress custom fields 101. The plugin just creates a UI.
@Robert, thanks a lot! I appreciate that. Hopefully he will like it!
You’ve done it again Justin. Very handy feature indeed.
Merry Christmas y’all
I too am very exited about this.It just makes things a bit more easy (and cool).Like many of the others above, I would love to use snippets in more than one place on a post.
Thanks for the great work Justin.
That sounds really useful! I have a few articles lined up which I would like to include videos in so I’ll experiment with this widget. Might make a nice custom image gallery too.
Nice share dude! I’m glad I ran into this blog, you have some great content here and I can’t wait to share it! I have a great Digg-style site for bloggers and internet marketers and I’m sure your post here will end up on the front page, so I’ll submit it and check back with your blog soon. Keep up the awesome work
is this plugin is available for wordpress 2.9? I’m using that version of wordpress right now…
Great plug in. Thanks!
thanks for sharing, i’ll give it a try, my theme always gets messed up when i install some plugins hope this one will work fine. :\
Man. This plugin rock… Thanks
really nice plugin I should give a try to my own site, thanks for the share
Justin
Great plugin!
Maybe you know how to fix this : I have added a shortcode to a text widget, which displays some content in a widgetized area.
But the content div genereated by the shortcode appears before the widget div:
instead of
Your plugin places the content correctly inside the widget div, so maybe you can tell me how to achieve the same effect?
Great Plugin !
Very usefull, thank you for sharing it.
wow, great discovery! I always looked for something like that. +1 for you Justin, thank you very much!
Nice plugin Justin. Thank you very much!
greetings, nagradne igre
You don’t need to be told this, Justin, but you’re a mastermind. This is fantastic.
A quick question: how could I style the header of this widget differently to the headers used for other widgets in my single post sidebar?
Thanks!
Thanks for the plugin JUSTIN!
Another amazing plugins from wordpress ..
I suppose it is the best wordpress than others,,,
interesting article from you,,
and of course, also written by a professional person like you,,
good plugin i will try this on my blog thanks for sharing
You rock man. I am new to your blog. Thank you so much for sharing such a nice plugin. Keep it up.
This is an awesome plugin Justin, well done for your hard work.
Is it possible to get multiple snippet post settings for one single post, i.e 3, to insert a google map, videos and extra info?
Will it be included in future updates or can you help me modify the codes please, I’ll pay a fee.
My email and twitter is attached here.
Thanks.
Been looking for something like this all day. Got it working on one of my blog. Thanks for the plugin work perfectly.
For what it’s worth, there is a slight mistake in the spelling (two ‘ss’) when viewing the list of plugins.
It appears as: My Snippetss
Hi there,
First of all: Awesome plugin! Was looking for this for quite some time
The only thing I can’t figure out is the way the text/html appears on my website.
There is no margin or padding at all. The text just appears right next to the start of the widget ( to the border to the left). Is there any way I can add a padding to this plugin so it will appear more centered and in alignment with the rest of my widgets?
Thanks in advance!
I am trying to have a widget displayed for a specific user but unfortunately I cannot get it to work.
I have found out how to get the current user id and display a text for this user only, but I don’t know how to convert to Widget Logic code.
This is what I am trying to do:
Can anyone tell me how I can get the above to work with Widget Logic?
Thaks Justin this just a great and useful plugin !
Thanks for this plugin, im using it already on 3 of my sites
Very powerful .
You are my savior
been looking for this plugin for a long time – didn’t even think it existed.
thank you!!!
Spoke too soon I guess ? Trying out your snippet on one of my custom city portal themes and nothing seems to be happening – it worked fine on WP default theme.
Sound exactly what im looking for if it can display html and javascript together. Will try it out. Thanx!
Does this plugin still works for current WP version?
I like the idea. It’s both post snippets and Widget Logic together.
You should rename the widget as “Post related Widget”, or something like that.
This plugin works for the current WP verision (my answer to sergio that have written above me).
Anyway, im using this plugin alreday on all of my sites. I dont see anything bad with it. Cred to you Justin. Because this is a very powerful plugin.
Sound exactly what im looking for if it can display html and javascript together. Will try it out. Thanx!
Justin thank you again
this smart plugin saved my day.
I had to convert html site to WP and only solution was this Snippets plugin.
Some wide (widget) content different on every page was real problem.
I know you said above U do not like Visual editor, but can be handy here
regards
test site using a city theme which uses “places” instead of posts makes this plugin pretty much useless – Q = how difficult would it be to make your plugin work with custom post types ?
anyone that can make this happen for a reasonable fee $$$ ?
much appreciated -
thx JC