Disgrifiad
Collapsing Categories creates an expandable list of categories and
subcategories. It can also expand to show posts. The primary usage is as a
widget, but you can also use the code in your theme manually if you wish (see
installation instructions)
Options
Options can be set
from the block panel. If you wish to insert the code into your theme manually
instead of using a widget, you can use the following options. These options
can be given to the collapsCat()
function either as an array or in query
style, in the same manner as the wp_list_categories
function.
$defaults=array(
'showPostCount' => true,
'inExclude' => 'exclude',
'inExcludeCats' => '',
'showPosts' => true,
'showPages' => false,
'linkToCat' => true,
'olderThan' => 0,
'excludeAll' => '0',
'catSortOrder' => 'ASC',
'catSort' => 'catName',
'postSortOrder' => 'ASC',
'postSort' => 'postTitle',
'expand' => '0',
'defaultExpand' => '',
'postTitleLength' => 0,
'accordion' => 0,
'catfeed' => 'none',
'taxonomy' => 'category',
'showPostDate' => false,
'postDateAppend' => 'after',
'postDateFormat' => 'm/d',
'useCookies' => true,
'showTopLevel' => true,
'postsBeforeCats' => false,
'expandCatPost' => true,
'debug'=>'0'
);
- inExclude
- Whether to include or exclude certain categories
- ‘exclude’ (default)
- ‘include’
- Whether to include or exclude certain categories
- inExcludeCats
- The categories which should be included or excluded
- showPages
- Whether or not to include pages as well as posts. Default if false
- linkToCat
- 1 (true), clicking on a category title will link to the category archive (default)
- 0 (false), clicking on a category title expands and collapses
- catSort
- How to sort the categorys. Possible values:
- ‘catName’ the title of the category (default)
- ‘catId’ the Id of the category
- ‘catSlug’ the url of the category
- ‘catCount’ the number of posts in the category
- ‘catOrder’ custom order specified in the categorys settings
- How to sort the categorys. Possible values:
- catSortOrder
- Whether categories should be sorted in normal or reverse
order. Possible values:- ‘ASC’ normal order (a-z 0-9) (default)
- ‘DESC’ reverse order (z-a 9-0)
- Whether categories should be sorted in normal or reverse
- postSort
- How to sort the posts. Possible values:
- ‘postDate’ the date of the post (default)
- ‘postId’ the Id of the post
- ‘postTitle’ the title of the post
- ‘postComment’ the number of comments on the post
- ‘postOrder’ sort by menu order
- How to sort the posts. Possible values:
- postSortOrder
- Whether post should be sorted in normal or reverse
order. Possible values:- ‘ASC’ normal order (a-z 0-9) (default)
- ‘DESC’ reverse order (z-a 9-0)
- Whether post should be sorted in normal or reverse
- expand
- The symbols to be used to mark expanding and collapsing. Possible values:
- ‘0’ Triangles (default)
- ‘1’ + –
- ‘2’ [+] [-]
- ‘3’ images (you can upload your own if you wish)
- ‘4’ custom symbols
- The symbols to be used to mark expanding and collapsing. Possible values:
- customExpand
- If you have selected ‘4’ for the expand option, this character will be
used to mark expandable link categories
- If you have selected ‘4’ for the expand option, this character will be
- customCollapse
- If you have selected ‘4’ for the expand option, this character will be
used to mark collapsible link categories
- If you have selected ‘4’ for the expand option, this character will be
- postTitleLength
- Truncate post titles to this number of characters (default: 0 = don’t
truncate)
- Truncate post titles to this number of characters (default: 0 = don’t
- accordion
- When set to true, expanding one category closes all others at that level
- catfeed
- Whether to add a link to the rss feed for a category. Possible values:
- ‘none’ (default)
- ‘text’ shows RSS
- ‘image’ shows an RSS icon
- Whether to add a link to the rss feed for a category. Possible values:
- taxonomy
- Type of taxonmy to display. Possible values:
- ‘category’ (default)
- ‘link_category’
- ‘post_tag’
- ‘both’ (categories and tags)
- any other registered taxononmy (e.g. recipe press uses recipe-categories)
- Type of taxonmy to display. Possible values:
- showPostDate
- When true, show the date of each post
- postDateAppend
- Show the date before or after the post title. Possible values:
- ‘after’ (default)
- ‘before’
- Show the date before or after the post title. Possible values:
- postDateFormat
- What format the post date is in. This uses the standard php date
formatting codes
- What format the post date is in. This uses the standard php date
- useCookies
- When true, expanding and collapsing of categories is remembered for each
visitor. When false, categories are always display collapsed (unless
explicitly set to auto-expand). Possible values:- 1 (true) (default)
- 0 (false)
- When true, expanding and collapsing of categories is remembered for each
- showTopLevel
- When set to false, the top level category will not be shown. This could
be useful if you only want to show subcategories from one particular
top-level category- 1 (true) (default)
- 0 (false)
- When set to false, the top level category will not be shown. This could
- postsBeforeCats
- When set to true, posts in category X will be ordered before
subcategories of category X- 1 (true)
- 0 (false) (default)
- When set to true, posts in category X will be ordered before
- expandCatPost
- When set to true, any category to which a post is assigned will
automatically be expanded on a single post page.- 1 (true) (default)
- 0 (false)
- When set to true, any category to which a post is assigned will
- showEmptyCat
- When set to true, empty categories are shown
- 0 (false) (default)
- 1 (true)
- When set to true, empty categories are shown
- debug
- When set to true, extra debugging information will be displayed in the
underlying code of your page (but not visible from the browser). Use
this option if you are having problems
- When set to true, extra debugging information will be displayed in the
Examples
collapsCat('catSort=ASC&expand=3&inExcludeCats=general,uncategorized')
This will produce a list with:
* categories shown in alphabetical order
* using images to mark collapsing and expanding
* exclude posts from the categories general and uncategorized
`
<?php
echo '
- ‘ . “\n”;
if (function_exists(‘collapsCat’)) {
collapsCat(array(
‘postSort’ => ‘postDate’,
‘postSortOrder’ => ‘DESC’,
) );
} else {
wp_get_categories(‘your_options_here’);
}
echo “
\n”;
?>
`
Demo
I use this plugin in my blog at http://robfelty.com
CAVEAT
Currently this plugin relies on Javascript to expand and collapse the links.
If a user’s browser doesn’t support javascript they won’t see the links to the
posts, but the links to the categories will still work (which is the default
behavior in wordpress anyways)
Lluniau Sgrin
Blocks
This plugin provides 1 block.
- Collapsing Categories A Gutenberg block to show a collapsible list of your categories
Gosod
IMPORTANT!
Please deactivate before upgrading, then re-activate the plugin.
Unpackage contents to wp-content/plugins/ so that the files are in a
collapsing-categories directory.
Widget installation
Activate the plugin, then simply go the
Presentation > Widgets section and drag over the Collapsing Categories Widget.
Manual installation
Activate the plugin, then insert the following into your template: (probably
in sidebar.php). See the Options section for more information on specifying
options.
<?php
echo "<ul class='collapsCatList'>\n";
if (function_exists('collapsCat')) {
collapsCat();
} else {
wp_get_categories('your_options_here');
}
echo "</ul>\n";
?>
Cwestiynau Cyffredin
-
How do I use different symbols for collapsing and expanding?
-
If you want to use images, you can upload your own images to
http://yourblogaddress/wp-content/plugins/collapsing-categories/img/collapse.gif
and expand.gifThere is an option for this.
-
I have selected a category to expand by default, but it doesn’t seem to work
-
If you select a sub-category to expand by default, but not the parent
category, you will not see the sub-category expanded until you expand the
parent category. You probably want to add both the parent and the
sub-category into the expand by default list. -
I can’t get including or excluding to work
-
Make sure you specify category names, not ids.
-
There seems to be a newline between the collapsing/expanding symbol and the
-
category name. How do I fix this? =
If your theme has some css that says something like
-
that is the problem.
You probably want to add a float:left to the .sym class -
No categories are showing up! What’s wrong?”
-
Are you using categories or tags? By default, collapsing categories only lists
categories. Please check the options in the settings page (or in the widget if
you are using the widget) -
How do I change the style of the collapsing categories lists?
-
As of version 2.0, there are several default styles that come with
collapsing-categories. You can choose from these in the widget settings , or you
can create your own custom style. A good strategy is to choose a default, then
modify it slightly to your needs.The following classes are used:
* collapsing-categories – applied to all ul and li elements
* list – applied to the top-level ul
* item – applied to each li which has no sub-elements
* expand – applied to a category which can be expanded (is currently
collapsed)
* collapse – applied to a category which can be collapsed (is currently
expanded)
* sym – class for the expanding / collapsing symbolAn example:
<ul id='widget-collapscat-15-top ' class='collapsing-categories list'> <li class='collapsing-categories post'><a href='http://mysite.com/your-website/about-your-own-site/' title='About your own site'>About your own site</a> </li> <li class='collapsing-categories'><span class='collapsing-categories expand' onclick='expandCollapse(event, "▶","▼", 1, "collapsing categories"); return false'><span class='sym'>▶</span>Web hosting</span> <ul id='collapsCat-176-15' style="display:none"> <li class='collapsing-categories post'><a href='http://mysite.com/your-website/web-hosting/about-webhosting/' title='About webhosting'>About webhosting</a> </li> <li class='collapsing-categories post'><a href='http://mysite.com/products/webhosting-1/' title='Webhosting #1'>Webhosting #1</a> </li> <li class='collapsing-categories post'><a href='http://mysite.com/products/webhosting-2/' title='Webhosting #2'>Webhosting #2</a> </li> </ul> </li> <!-- ending subcategory -->
Adolygiadau
Contributors & Developers
“Collapsing Categories” is open source software. The following people have contributed to this plugin.
Cyfranwyr“Collapsing Categories” has been translated into 2 locales. Thank you to the translators for their contributions.
Translate “Collapsing Categories” into your language.
Interested in development?
Browse the code, check out the SVN repository, or subscribe to the development log by RSS.
Cofnod Newid
3.0.8 (2023.12.01)
- Updated deprecated
__experimentalGroup
togroup
- Compatible with WordPress 6.4.1
- Got rid of some warning messages
3.0.7 (2023.10.10)
- Fixed another issue with subcategory only option (Again, Thanks Boris for testing)
3.0.6 (2023.10.10)
- Fixed another issue with subcategory only option (Thanks Boris for testing)
3.0.5 (2023.10.02)
- Fixed issue with subcategory only option (Thanks Boris for testing)
3.0.4 (2023.09.12)
- Fixed issue with including/excluding categories in the settings
3.0.3 (2023.03.28)
- Added back in accordion option
- Fixed COOKIES
- added SameSite to cookies
- Fixed sub-category post counts
- Some other code cleanup
3.0.2 (2023.03.27)
- Some fixes based on testing feedback
3.0.1 (2023.03.25)
- More testing
3.0.0 (2023.03.24)
- Converted to Gutenberg block to be usable by block themes
- Got rid of dependency on jQuery (no more animations)
- Compatible with PHP 7.4 and PHP 8.2
2.2.7 (2020.08.25)
- Some fixes for manual use (not as a widget)
- Tested with WordPress 5.5
2.2.6 (2020.04.21)
- Fixed bug which would exclude categories without subcategories when not showing posts
2.2.5 (2020.04.20)
- Fix possible unset index error
- Updating jQuery to remove deprecated “live” function ( thanks Torsten Wirth for the suggested fix)
2.2.4 (2020.04.10)
- Fix for when a category description has line breaks in it
2.2.3 (2020.04.09)
- Tested on WordPress 5.4
- Fixed an issue which caused some sites not to have javascript loaded
properly - Fixed a number of PHP / WP_DEBUG warnings
2.2.2 (2020.04.01)
- Fixed bug with non-numerical value https://wordpress.org/support/topic/warning-a-non-numeric-value-encountered-in-collapscatlist-php-on-line-267/
2.2.1 (2020.04.01)
- Fixed bug with possible undefined variable warning introduced in 2.2.0
2.2.0 (2020.03.29)
- Compatible with PHP 7.4
- Compatible with WordPress 5.3
- Fixed bug where if $posts is not an array, it would generate a PHP warning
- Unregistering filters based on https://wordpress.org/support/topic/breaks-taxonomies-tag-cloud-because-of-filters-not-unregistered/
- Stripping tags from title attributes https://wordpress.org/support/topic/strip-tags-from-title-attributes/
- Fix for custom taxonomies from https://wordpress.org/support/topic/currently-viewed-item-does-not-display-properly-with-custom-taxonomies/
- Added option to display categories asynchronoously using WP Rest API and AJAX
2.1.3 (2019.05.02)
- Compatible with PHP 7.2
- Compatible with WordPress 5.1
2.1.2 (2017.12.13)
- Fixed another bug with “active” class when displaying category archive
2.1.1 (2017.12.12)
- Compatible with WP 4.9
- Fixed bug with “active” class when displaying category archive
2.1 (2017.11.06)
- Compatible with WP 4.8.3
- Added “active” class to categories which correspond to category of current post
2.0.9 (2017.08.18)
- Compatible with WP 4.8
- General code cleanup to avoid warnings
2.0.8 (2016.08.23)
- Fixed bug with displaying html entities in titles (props to harnwerd for reporting the bug)
2.0.7 (2015.11.01)
- Replaced deprecated API calls with newer ones
2.0.6 (2015.08.12)
- Compatible with WP 4.3
2.0.5 (2014.09.05)
- Compatible with WP 4.0
2.0.4 (2013.08.02)
- fixed bug where a sub-category with newlines in the description would
break expanding and collapsing
2.0.3 (2012.06.20)
- fixed jquery loading for WP 3.4
2.0.2 (2011.11.01)
- removed link to spammy site
2.0.1 (2011.08.08)
- fixed include category option
2.0 (2011.07.29)
- Can now use custom taxonomies
- Don’t display any tags for title if title is empty
- Easier style handling
- Updated settings page
- Fixed bug with extraneous li when not showing posts (thanks neoen for
pointing it out) - Fixed bugs with styling in IE
- Added option to show empty categories
- Added accordion option
- Added ability to sort posts by menu order
1.2.2 (2010.08.05)
- fixed self class for category archive pages (error pointed out by ltache)
1.2.1 (2010.07.25)
- Fixed bug where top-level categories did not show up if only had posts in
sub-sub categories. - Fixed post counting errors
1.2 (2010.06.18)
- Added option to automatically expand categories to which a post is
assigned on single post pages - Storing posts in a javascript array and only adding to the DOM when
requested (speeds page load) - fixed bug where empty subcategory with non-empty subsubcategory doesn’t
show up
1.1.1 (2010.01.28)
- Added option to display posts before categories
- Fixed bug with assigning self class to posts in sub-categories
- Refactored code to reduce number of database reads when using multiple
instances of the widget - Switched from scriptaculous to jquery. No longer conflicts with plugins
which use mootools (e.g. featured content gallery) - Changed css class called “post” to “item” to avoid conflicts with other
commonly used css classes
1.1 (2010.01.03)
- Bug fixes
- Fixed xhtml validation error (thanks Mathie)
- Fixed incorrect link bug (thanks andydv)
- Fixed some css issues
- Manual version works even if no options are given
- Fixed include option
- Fixed self class problems
- Fixed link to settings page from widget options (thanks wp.Man)
- Fixed rss options (thanks wp.Man)
- New options and features
- Added option to hide top level category names
- Changed css classes to make them more consistent with other collapsing
plugins (thanks Bernhard Reiter)
- Internationalization and localization
- Added Russian localization
- Added German localization (thanks Bernhard Reiter)
1.0.2 (2009.07.19)
- Fixed older than option
- Added advanced options section in configuration
- Added advanced option to remember expanding and collapsing for each
visitor (using cookies) - Now issuing a correct id for each ul when using widgets
- Small change in manual installation
- TODO: Added advanced option to expand category when viewing the category
archive page - Permalinks which use author now work correctly
1.0.1 (2009.06.22)
- Fixed some problems with cookies on page load
1.0.beta (2009.06.08)
- Added option to show post date
- Fixed some options that were broken in 1.0.alpha
1.0.alpha (2009.05.01)
- Compatible with wordpress 2.8 widget api (incompatible with 2.7.1 and
earlier) - Can now add options manually when using manually instead of widget
- When using tags, link now points to correct location
0.9.8 (2009.04.17)
- Fixed triangle problem
0.9.7 (2009.04.16)
- fixed a few bugs introduced in 0.9.6
0.9.6 (2009.04.15)
- Added option to group posts into misc category
- Switched role handling to proper API use (to control whether or not the
settings page shows up) - Added option for custom symbols
- No longer requires footer
- Updated javascript file
- Cleaned up code a bunch
0.9.5 (2009.03.22)
- Fixed some more settings panel issues
- Truncate post title now working for posts in sub-categories
- Works even faster now for blogs with many posts
- Fixed option to show only tags
- Fixed previews for style settings
- Categories which do not have any posts due to date exclusion no longer
show up - Restored compatibility with my category order plugin
- Better internationalization support
0.9.4 (2009.03.09)
- Fixed issue with multiple instances
0.9.3 (2009.03.08)
- Fixed links to sub-categories
0.9.2 (2009.03.07)
- Tweaked default style
- Fixed bug when not using permalinks
0.9.1 (2009.03.02)
- Fixed bug where top level categories would not be displayed if they
have no subcategories, and show only sub-categories is selected - Can leave sidebar ID option blank if desired
0.9 (2009.03.01)
- Added option to exclude posts older than certain number of days
- Widened widget options interface
- Updated text of widget options some
* Categories no longer get nested if for some reasons there are no posts
showing up for a category
* Added option to exclude post X in categories A and B when either A or B
is excluded - Post count is now more accurate
- Better internationalization for post and category titles
- Added truncate post title option
- Settings panel only available for admin
- fixed settings panel problems
- greatly increased speed for blogs with lots of posts and categories
- added new style selection method
- If current page is in category X, then category X will be expanded
(thanks to Bernhard Reiter)
0.8.5 (2009.01.23)
- fixed settings panel problems
0.8.4 (2009.01.15)
- fixed sql queries, which seems to be working for most people now
- Got rid of empty quotes in query when no in/exclude is used
- Added option to list categories, tags, or both
0.8.3 (2009.01.08)
- Refixed settings page for manual usage
- Changed category query in the hopes that it works for more people
0.8.2: (2009.01.07)
- Added nofollow option
- Added version to javascript
- not loading unnecessary code for admin pages (fixes interference with
akismet stats page - fixed settings page for manual usage
0.8.1 (2009/01/06)
- Finally fixed disappearing widget problem when trying to add to sidebar
- Added debugging option to show the query used and the output
- Moved style option to options page
0.8 (2008/12/08)
- fixed javascript bug where thisli.parentNode was null
- made javascript more flexible so that all collapsing X plugins can share
more code - Now adds default options to database upon activation for use manually
- styling now done through an option
- inline javascript moved to footer for faster page loading
0.7.1 (2008/12/01)
- fixed javascript bug in IE7
0.7 (2008/11/22)
- Cookie handling now affects categories that are expanded by default too
- Can now be used either as a widget or manually
- Got rid of the stupid float left from 0.6.6
0.6.6 (2008/11/21)
- Added a float left to .sym css to make it compatible with more themes
0.6.5 (2008/11/18)
- Now uses cookies to keep categories expanded if they have been clicked on
0.6.4 (2008/11/10)
- Fixed a minor bug in with animation option not being properly set by
default
0.6.3 (2008/10/03)
- Added option to animate expanding and collapsing
- Added option to add rss feeds for each category
0.6.2 (2008/09/11)
- Fixed display of expand and collapse symbols when using images
- Improved font handling and styling of text symbols
0.6.1 (2008/09/01)
- Improved styling so that collapsing and expanding symbols use a
fixed-width font, but category names do not - When using the option to have category names trigger expansion, and not
showing posts, categories with no subcategories now link to the category - Added option to use images instead of html for collapse/expand characters
- +/- now uses UTF-8 encoding instead of html entities (may not work for
pages not encoded in UTF-8
0.6 (2008/08/27)
- Can have multiple instances of widgets, each with separate options
- No longer works as non-widget
- All options are stored in one database row
- Added more sorting options
- Added option to include or exclude certain categories
- Added option to expand certain categories by default
- Added option to have category names either link to category archive or to
activate expanding and collapsing
0.5.10 (2008/08/20)
- minor bug fix. Fixed option to optionally show pages
0.5.9 (2008/08/07)
- minor bug fix – added space before category count
- Added option to sort by category (term) order
- Added option to sort by category (term) count (note that it sorts by the
count of the parent category, so categories with many subcategories, but
not many posts themselves will be out of order - Added option to sort posts within categories
0.5.8 (2008/06/15)
* bug fix - category description now correctly appears in title attribute
if there is a description for a given category
* implemented a few more changes to work towards internationalization
0.5.7 (2008/05/23)
- fixed misnamed class in javascript (collapsArch -> collapsCat)
- added font-family definition to css to make it monospace for +/-
- added another option with brackets around the +/-
0.5.6 (2008/05/23)
- fixed bug such that subcategories would not display the expand and
collapse icons - fixed bug that categories with subcategories that have posts, but do not
have posts themselves will be displayed - Thanks to [Andy] (http://www.onkelandy.com/blog) for both of these bug
notices
0.5.5 (2008/05/19)
- fixed bug – html now validates when not displaying posts
- new option – choose between arrows or +- for expanding and collapsing
- tweaked exclude option to function better with collapsing categories
0.5.4
- fixed bug – was using hard-coded wp_ prefix in one SQL query.
Now using $wpdb-> instead
0.5.3
- count is now correct for all subcategories
0.5.2
- Added option to exclude certain categories
- Added option to sort categories by slug
0.5.1
- options in widget seem to work now
- removed duplicate entries due to tag + category
0.5
- Added option to not show posts
- Added option to change title in widget
- Now is condensed into one plugin
0.4.4
- using unicode number codes in css stylesheet
- fixed bug with duplicate entries in subcategories
0.4.3
- nicer list indenting
- re-fixed permalink bug introduced sometime after version 0.3.5
0.4.2
- fixed bug with extraneous
<
ul>
0.4.1
* fixed bug with get_sub_cat definition problem in WP 2.5. Looks like it
had something to do with nested functions maybe
0.4
- Verified to work with wordpress 2.5
- Now has custom styling option through the collapsCat.css stylesheet
- updated screenshots
- moved javascript into collapsCat.php and got rid of separate file
0.3.7
- strips html tags from post titles now
0.3.6
- Fixed bug introduced in version 0.3.5 where all links in a category
pointed to the same post
0.3.5
- Now links should work with all sorts of permalink structures. Thanks to
Krysthora http://krysthora.free.fr/ for finding this bug
0.3.4
- Added option to sort categories by id or name
0.3.3
- fixed bug in headers when collapsCat is not loaded
- fixed a few minor markup issues to make it valid xhtml
0.3.2
- posts now have the class “collapsCatPost” and can be styled with CSS.
Some styling has been added in collapsCat.php - removed list icons in front of triangles
0.3.1
- Added option to make post links to index.php, root, or archive.php, like
collapsing-categories - Fixed link to category listings
0.3
- Now uses only 2 database queries instead of 1 + 2*(count(categories))
- Now supports infinite levels of subcategories
0.2.2:
- Added option to show pages in list or not
0.2.1:
- Added collapsing class to
- s with triangles for CSS styling
- Added style information to make triangles bigger and give a pointer
cursor over them - Added title tags to triangles to indicate functionality
* Checking whether some of the same functionality from collapsing-categories
has already been loaded (for example the javascript file) in order to
avoid redundancy
0.2:
- Changed name from Fancy categories to Collapsing categories
- Changed author from Andrew Rader to Robert Felty
- Added triangles which mark the collapsing and expanding features
That is, clicking on the triangle collapses or expands, while clicking
on a category links to the category list for the said category.
This uses html entities (dings) instead of images, for a variety of
reasons - Lists the titles of posts, instead of just listing subcategories
- Removed the rel=’hide’ and rel=’show’ tags, because they are not xhtml
1.0 compliant. Now uses the CSS classes instead
* MOST IMPORTANTLY — is compatible with both the pre 2.3 database which
uses categories, and the 2.3+ database structure which uses the tag
taxonomy
Fancy Categories Changelog
0.1:
Initial Release