Wordpress Toggle Category widget set: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
I have a [http://news.thedigitalmachine.com/category/chatter/ Chatter category] on my tech blog that's really just for my own notes-to-self. And sometimes I want to see it, sometimes I don't. And I certainly don't want first-time visitors to have to see it. | I have a [http://news.thedigitalmachine.com/category/chatter/ Chatter category] on my tech blog that's really just for my own notes-to-self. And sometimes I want to see it, sometimes I don't. And I certainly don't want first-time visitors to have to see it. | ||
The solution I came up with was to provide a persistent toggle that would turn on/off the Chatter content. It starts "off", but any blog visitor can toggle it at any time. | The solution I came up with was to provide a persistent toggle that would turn on/off the Chatter content. It starts "off", but any blog visitor can toggle it at any time. See it in action on my [http://news.thedigitalmachine.com tech blog]. | ||
There are three widgets in the plugin: the toggle itself, and two widgets that reflect the toggle state, a category list and a list of recent posts. | I've packaged the functionality into a set of Wordpress widgets, available for download [http://thedigitalmachine.com/files/widget_toggle_chatter.php here] as a plugin. There are three widgets in the plugin: the toggle itself, and two widgets that reflect the toggle state, a category list and a list of recent posts. | ||
NOTE: Current status: | NOTE: Current status: |
Revision as of 04:47, 29 July 2008
I have a Chatter category on my tech blog that's really just for my own notes-to-self. And sometimes I want to see it, sometimes I don't. And I certainly don't want first-time visitors to have to see it.
The solution I came up with was to provide a persistent toggle that would turn on/off the Chatter content. It starts "off", but any blog visitor can toggle it at any time. See it in action on my tech blog.
I've packaged the functionality into a set of Wordpress widgets, available for download here as a plugin. There are three widgets in the plugin: the toggle itself, and two widgets that reflect the toggle state, a category list and a list of recent posts.
NOTE: Current status:
- The widgets contain hardcoded settings for the category number. You'll have to edit the plugin directly until I add widget settings.
- I have some CSS markup cleanup to do. You can do it yourself in the plugin if you're faster than me. :>
- You will want to modify your theme's index.php file to reflect the toggle's state. This is easy, and covered in the instructions.
Instructions:
- Download the plugin and extract the files into your plugins directory.
- Go to your Plugins page and activate the Toggle Chatter plugin.
- Go to your Design -> Widgets page and add the widgets to your sidebar.
- Update your theme's index.php file as follows. Right before the loop, add this block of code (changing the category number as needed):
<?php $include_chatter = $_COOKIE['chatter']; if (is_home()) { if($include_chatter != 'yes') { query_posts($query_string . "&cat=-2"); } } ?>