logo
  • Home
  • About
  • Plugins

Subscribe to Articles

Fun with Categories

Fun with Categories is a WordPress plugin that was written to provide the option to list posts that fall into both of two named categories instead of just one.

The plugin was written to provide a specific functionality, in a specific way, for a specific site, and amended for general use.

Version

Version 1.1 - December 2008

Tested against 2.7 beta 3, extra admin functions added.

Installation

Save fun-with-categories.php into wp-content/plugins/ and activate using the admin options.

How it works

To display post filtered by two categories you must use one the following permalink structures:

http://www.yoursite.com/categories/category1name/category2name/

http://www.yoursite.com/index.php/categories/category1name/category2name/

It doesn’t matter which way round they are in order to work; however, if you want to make the category titles display consistently then you might want to make sure you always put them the same way round.

Templates

This plugin will look to see if there is a template file called categories.php in your theme folder. If not it will check for archive.php and failing that will revert to index.php as usual.

Conditional Tags

To compliment the existing conditional tags this plugin adds the following:

is_dual_categories()

This returns true or false to determine if the posts are being filtered by two categories.

Example:

if ( is_dual_categories() )
{
echo 'Now filtering by dual categories';
}

Include Tags

To compliment the existing functionality the following have been added

dual_cat_titles();

This is the dual category equivalent to single_cat_title() used on the archive page.

By default this outputs both category names with “and” between them.

There are two options:

Which category:

show the first (1) , second (2), or both (0) categories:

dual_cat_titles(1)

Between:

If showing both categories choose the text to go between them (including spaces):

dual_cat_titles(0, ' and ')

An example of its use:

The URL reads: http://www.mysite.com/index.php/categores/india/photographs/

The code reads:

<strong><?php dual_cat_titles(2) ?> from <?php dual_cat_titles(1) ?></strong>

The page displays: Photographs from India

Dual Categories Base

In WordPress 2.7 you can change the URL base used for dual categories from the permalink settings page. By default dual categories permalinks will be /categories/cat1/cat2/ if you enter a word in the dual categories base field you can change it /anything/cat1/cat2/.

dual-cat-base

Download

Download the plugin from WordPress Extend

Recommended

WP Remix Banner

Archives

  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008
  • December 2007
  • November 2007
  • October 2007

Tags

2.7 2.8 Admin Advertising Air Blogging blogs Cache Cliche Coding Comments Content Types CSS Curry Death development Disqus Features Habari image Interview Licensing Modes Monday Poll New Features Organisation Personal Platform Plugin Plugin-Practices plugins Plugin update Poll premium Readers Reviews Search Simplification Snippets Spam Themery Themes tools User Interface Widgets WLTC

Copyright 2009 Fun with WordPress - All Rights reserved.

Wordpress theme by: WPUnlimited