A few months ago I received suggested it might be a good idea to allow the gallery shortcode to retrieve attachments from a category as part of my Media Categories plugin.
So here it is, Media Categories 1.2 extends the native WordPress Gallery Shortcode to allow you to select a category to display via a newly added ‘category’ parameter which can take either a term_id OR a slug.
Normally the gallery shortcode only shows you images that have been attached to the current post, or a post id passed as an argument. This normal behavior is preserved with Media Categories 1.2, however when invoking the ‘categories parameter, the current post is ignored, unless its id is explicitly passed.
[gallery category='slug' id='12']
In the example above, the gallery shortcode will create a gallery of any images that in the category called ‘slug’ AND are attached to post id 12. If the id is not explicitly passed, then it will simply return all images from the category.
As I’ve stated, if you don’t invoke the category parameter, the gallery shortcode will behave as normal, so this plugin will not interfere with how galleries already in use will behave.
I have a few additional updates coming soon for this plugin, per another request I received via the plugin directory forums, version 1.3 will include a filter so that developers can change the taxonomy at will.
Thanks for using the plugin, as always I appreciate bug reports and feature requests, I hope you find good use for this new feature.
This plugin has seen a flurry of bug fixes and updates since 1.3 was released and we’re now on version 220.127.116.11. I am really sorry for having so many updates back-to-back.
Everything since 1.3 is bug fixes, here is a summery of what was fixed.
- `category.php` templates were not being loaded (somewhere down the line I must have removed it by mistake)
- In cases where the current category was neither parent nor child, the plugin would fail to load anything from the hierarchy other
- Lastly, I screwed up a commit, and the changes for 1.3.2 didn’t go out, hence 18.104.22.168
The Simple Hook Widget just got a little bit less simple.
Since I released this originally, it seems people have a hard time understanding what this plugin could possibly be good for. I can understand that given the vague nature of it being a plugin for hooks.
Additionally, there is a signficant security problem in having this plugin turned on for a server where other non-developers have access to the widgets panel – primarily thats because this plugin lets you do ANYTHING !! Including the use of hooks that are part of core, and could cause serious problems if they are run at the wrong time (such as in the sidebar.
This update introduces the ability for developers to provide an array of hooks, and have those hooks show up as a drop down menu in the widget. Additionally, there is another hook which allows for a default value for that hook.
There is also a complete example packaged with this plugin, for how to setup your own list of hooks, how to set a default, and an exceedingly simple example of how to actually do something with a chosen hook.
Have fun, and please please please be CAREFUL using this plugin.
I’ve release an update to the Category Template Hierarchy plugin, a particular bug report prompted the update but there are a couple of other changes as well.
I use this plugin for three sites I’ve worked on for Sears / Kmart, so over time I make minor changes to resolve issues I notice or improve how it works, but I don’t always have time to release those changes publicly.
A recent bug report forced to release a fix, and gave me an opportunity to update the plugin. Some of these changes effect how the plugin behaves, so it could impact your site if you depend on this plugin to keep your theme working. Here are the changes
- Improved performance be removing completely unnecessary logic to determine current category while building the list of potential templates to use. (No behavioral effect)
- Changed the filter used by the plugin. Before it used the very broad and general ‘template_redirect’ filter, but that caused obvious problem with other parts of the hierarchy, so not it uses the ‘category_template’.
- In addition to changing which filter is being used, the plugin used to `include()` the `get_query_template()` function, but now returns `locate_template`. This should resolve a bug where global variables such as $post were not available from within the loop.
- Logic in the `is_child_of_category()` and `is_parent_of_category()` has changed to check `!isset($child_category->parent) || !isset($parent_category)` instead of `empty($child_category) || empty($parent_category)`. This could effect your code if you use these conditional tags for anything in your theme.
The only item that does not effect any behavior is #1. Items #2 and #3 change the way the template hierarchy effect other parts of the native Template Hierarchy, so if you’ve seen strange behavior with non-category templates then you’ll definitely benefit from these changes. Item #4 is important as well, since it simply makes the conditional results much more accurate.
I don’t know how often people use the conditional functions, or how many of the couple thousand people who’ve downloaded this plugin actually use it at all – but I really appreciate the bug reports and any feedback. As I’ve said, I use these plugins myself on productions sites – so the public QA is always appreciated.
Download: WordPress Plugin Directory
This widget allows the user to insert a hook, with a name of their choosing, in any sidebar.
The hook can be anything, an existing hook from the WordPress Core, a plugin, a theme, or something you’ve come up with on the fly. Once the hook exists, your plugins, your theme, or the WordPress Core to make something happen with that hook.
This can be used in conjunction with other more complex plugins, to give the user control of then things occur (yes, that is intentionally vague). It can also serve as a quick alternative to making very simple widgets tied to code from a theme. Say you have a chunk of code which already exists on your site, you’d like to also have it placed in a sidebar, but don’t want to make a widget out of it (since its entirely theme-centric). You could simply hook this chunk of code to a custom hook and use the Simple Hook Widget to place that custom hook in the sidebar. This is absolutely not an endorsement toward that strategy for widget development, but there may be times where such on option is useful to a developer in a pinch.
This widget also contains an internal hook, which will be your hook, prefixed with simplehookupdate_. So if you use this plugin to create a hook name ‘testhook’, the widget, aside from creating the ‘testhook’ in the chosen sidebar location, will also create a hook called ‘simplehookupdate_testhook’. This hook occurs within the update method of the WP_Widget class, immediately before $instance is returned.
All in all its very simple, and intentionally so. I hope developers can find some useful uses for it – I know I already have a very complex plugin in the works that will utilize this. Please feel free to make suggestions or ask questions.