Code Styling Project

It’s not a bug, it’s always a feature.
  • Deutsch
  • English
  • rss
  • Home
  • Blog
  • Imprint
  • Development
  • Manuals
  • Bugfixing

WordPress Category Tree Chaos at “Write Posts”

codestyling | 07. December 2008 | 19:17

While writing new posts you will realize, that something is wrong with the tree view of all categories. WordPress lists all categories as tree and i expect that the defined tree structure will be shown all the time.

Unfortunately WordPress steps in with an unexpected manner which forces the tree view to be shown damaged. The sorting of already used categories for the actual post in front of tree breaks the tree view and makes a tree view obsolete.

Again i was searching the code lines at WordPress Core, that are responsible for this damaged display. Finally i found it at the file template.php inside the function wp_category_checklist. The function tries a pre-filter on categories, which already have been used for this post. This results into creation of 2 disjuct sets of categories:

  • categories already assigned to this post
  • all unassigned remaining categories

Afterwards both sets will be dumped as HTML tree views. Because of this rupture of tree connections only a part of the categories can be shown as tree view. All not found parent relations will result into appending the categories in linear order at the end of possible tree. The above shown image may illustrate this issue in a simple way.

The only solution i found is a modification of WordPress Core. That’s why i changed the file: wp-admin/includes/template.php at function wp_category_checklist and have commented out the pre-filtering:

The red marked section is the pre-filter not longer been executed but keeped for the moment at file. But i was also curious to know, what other WordPress versions have a similar coding to this. After inspectation of all versions beginning 2.7-RC1 downto 2.5.1 i realized, that this code can be found unchanged at all of them. So the patch can be applied to all this versions as shown here.

As you can see the result is a logical tree view, that displays correctly the relationship of all categories as expected. This patch is a simple solution to solve this issue. In my opinion the WordPress core team has to find a more sophisticated solution. If categories will be shown as tree than all relations should be displayed in a way that meets the parent relationship defined at category page.

I will register this issue at WordPress Bug Trac and will try to explain it there. Hopefully an appropriated solution will be published at upcomming releases of WordPress, but i’m afraid, that it is too late for next version 2.7 published soon.

The issue has been filed at WordPress Trac as follows: Ticket #8521

Categories
English, WordPress (US)
Comments rss
Comments rss

« WordPress 2.6.1 loads too many script.aculo.us components WordPress Localization - Features and future Development »

5 responses    Leave a comment

ricky

ricky

22.01.2009 | 08:10

Thanks for this post you really save me some time.

reply »

jimc

jimc

25.03.2009 | 17:32

Great find. Huge problem in WP.

reply »

josh

josh

30.04.2009 | 17:40

You are the man! Thanks so freaking much. This was a real oversight on WP’s part, and there is very little addressing this on the net.

Thanks again!

p.s. Some of the google keywords I used for this issue were as follows:
wp category hierarchy edit admin post breaks broken selected tree
Figured I’d stick them here just to make sure your page comes up more easily for this issue.

reply »

David McDonald

David McDonald

05.10.2009 | 08:07

Wondering if there is a way to do this without having to modify a core file?

reply »

Eivind

Eivind

03.12.2009 | 15:15

Thanks for this heads-up. Took me some time to find it. Looking at my 2.8.5 files, it seems that the code has been changed, but that the bug persists. Your fix cured the problem.

I looked at the ticket and it shows a link to a duplicate issue. Following that to its end, it says it’s closed because there is a better idea out there. But that idea was suggest YEARS ago, and has still not been implemented, so I think this is now a forgotten issue.

Please reopen a ticket (I’m not going to try because I’m not really a developer)

Anyway, thanks for the info

E

reply »

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Navigation

  • Common
  • jQuery at WordPress
  • WordPress (US)

Search

Newer Posts ...

  • “Page Columnist” - Posts and Pages at Column Layout
  • WordPress 2.8 changes the metabox model for admin pages
  • How to use Wordpress Metaboxes at own plugins
  • PHP function setlocale() … and numbers can be damaged
  • WordPress Localization - Features and future Development

Older Posts ...

  • WordPress 2.6.1 loads too many script.aculo.us components
  • WordPress 2.6 and the Text/Diff fatal errors
  • WordPress error during translation file usage - the reason
  • WordPress 2.5.1 - multi-lingual admin login (beta download)
  • WordPress 2.5.1 multi-lingual (1 of 3)
rss Comments rss valid xhtml 1.0 design by jide powered by Wordpress get firefox