Support » Plugins and Hacks » Single-category views, again

Single-category views, again

  • I know there have been a few threads about this, but I haven’t found a definitive solution yet.

    My goal is to produce a roughly “slashdot-style” blog, in that there be categories for posts, and a view mode which supports showing all of the posts in a given category and nothing else. The problem with doing this in WP seems to be the fact that if you use $cat to restrict the view to a specific catgegory, it does work, but it kicks it into “archive” mode, which shows posts differently and has some limitations. The reason I want to set up category views this way is that I’ll have a blog with 8 or 9 sections, probably with some people who will only ever be interested in one, and I want them to have an easily bookmarkable method to see the current front page, only filtered down to one category.

    Ryan Boran wrote a plugin that comes close to what I need, but you have to set in advance, in the code, which category you want to display, and I need it to be dynamic.

    To this end, I’ve got a temporary brute-force hack in place, which is to use a new cgi parameter “show” to indicate the category to show, and I use a slight tweak to Ryan’s plugin (below) to read the value from $_REQUEST[‘show’] and set the category restriction accordingly. Then I have category links within my template with links like “/?show=4” to show category 4. This seems to work, although it feels a little crude, and I need to make sure those links are spread around a lot within the system.

    $cats_to_show = $_REQUEST['show'] ? $_REQUEST['show'] : '1 2 3 4 5 6 8';

    Before I codify this, has anybody found a different / better way to accomplish it? Ideally I also want to set up subdomains to match category, so “tech.foo.com” will cause the “show” setting to kick in as well, like slashdot does with things like “apple.slashdot.org”. This can be done at the template level, again, I think, without modifying the code WP code itself.

    However, if there’s an easier or better way to do this before I launch, I’d love to hear anything other people have done that works, or any suggestions.

  • The topic ‘Single-category views, again’ is closed to new replies.